]> source.dussan.org Git - gitblit.git/commitdiff
Eliminate nearly all direct GitBlit singleton references in Wicket
authorJames Moger <james.moger@gitblit.com>
Sat, 16 Nov 2013 16:42:06 +0000 (11:42 -0500)
committerJames Moger <james.moger@gitblit.com>
Tue, 26 Nov 2013 21:07:04 +0000 (16:07 -0500)
This is the first step towards modularization and injection.  All
direct references to the GitBlit singleton within the Wicket pages
and panels have been replaced to proxy methods in the GitBlitWebApp
singleton.  There are still two Wicket classes which rely on the
GitBlit singleton; those require manual instantiation (servlet 3).

Change-Id: I0cdbbcf87959d590c446c99abb09c07c87c737bc

61 files changed:
src/main/java/com/gitblit/utils/MessageProcessor.java [new file with mode: 0644]
src/main/java/com/gitblit/wicket/AuthorizationStrategy.java
src/main/java/com/gitblit/wicket/GitBlitWebApp.java
src/main/java/com/gitblit/wicket/GitblitParamUrlCodingStrategy.java
src/main/java/com/gitblit/wicket/WicketUtils.java
src/main/java/com/gitblit/wicket/pages/ActivityPage.java
src/main/java/com/gitblit/wicket/pages/BasePage.java
src/main/java/com/gitblit/wicket/pages/BlamePage.java
src/main/java/com/gitblit/wicket/pages/BlobPage.java
src/main/java/com/gitblit/wicket/pages/ChangePasswordPage.java
src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java
src/main/java/com/gitblit/wicket/pages/CommitPage.java
src/main/java/com/gitblit/wicket/pages/DashboardPage.java
src/main/java/com/gitblit/wicket/pages/DocPage.java
src/main/java/com/gitblit/wicket/pages/DocsPage.java
src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java
src/main/java/com/gitblit/wicket/pages/EditTeamPage.java
src/main/java/com/gitblit/wicket/pages/EditUserPage.java
src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java
src/main/java/com/gitblit/wicket/pages/FederationPage.java
src/main/java/com/gitblit/wicket/pages/FederationRegistrationPage.java
src/main/java/com/gitblit/wicket/pages/ForkPage.java
src/main/java/com/gitblit/wicket/pages/ForksPage.java
src/main/java/com/gitblit/wicket/pages/LogoutPage.java
src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java
src/main/java/com/gitblit/wicket/pages/MyDashboardPage.java
src/main/java/com/gitblit/wicket/pages/OverviewPage.java
src/main/java/com/gitblit/wicket/pages/PatchPage.java
src/main/java/com/gitblit/wicket/pages/ProjectPage.java
src/main/java/com/gitblit/wicket/pages/ProjectsPage.java
src/main/java/com/gitblit/wicket/pages/RawPage.java
src/main/java/com/gitblit/wicket/pages/RepositoriesPage.java
src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
src/main/java/com/gitblit/wicket/pages/ReviewProposalPage.java
src/main/java/com/gitblit/wicket/pages/RootPage.java
src/main/java/com/gitblit/wicket/pages/RootSubPage.java
src/main/java/com/gitblit/wicket/pages/SendProposalPage.java
src/main/java/com/gitblit/wicket/pages/SessionPage.java
src/main/java/com/gitblit/wicket/pages/SummaryPage.java
src/main/java/com/gitblit/wicket/pages/UserPage.java
src/main/java/com/gitblit/wicket/panels/ActivityPanel.java
src/main/java/com/gitblit/wicket/panels/BasePanel.java
src/main/java/com/gitblit/wicket/panels/BranchesPanel.java
src/main/java/com/gitblit/wicket/panels/CompressedDownloadsPanel.java
src/main/java/com/gitblit/wicket/panels/DigestsPanel.java
src/main/java/com/gitblit/wicket/panels/FederationProposalsPanel.java
src/main/java/com/gitblit/wicket/panels/FederationRegistrationsPanel.java
src/main/java/com/gitblit/wicket/panels/FederationTokensPanel.java
src/main/java/com/gitblit/wicket/panels/FilterableProjectList.java
src/main/java/com/gitblit/wicket/panels/FilterableRepositoryList.java
src/main/java/com/gitblit/wicket/panels/GravatarImage.java
src/main/java/com/gitblit/wicket/panels/HistoryPanel.java
src/main/java/com/gitblit/wicket/panels/LogPanel.java
src/main/java/com/gitblit/wicket/panels/ProjectRepositoryPanel.java
src/main/java/com/gitblit/wicket/panels/ReflogPanel.java
src/main/java/com/gitblit/wicket/panels/RegistrantPermissionsPanel.java
src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java
src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.java
src/main/java/com/gitblit/wicket/panels/SearchPanel.java
src/main/java/com/gitblit/wicket/panels/TeamsPanel.java
src/main/java/com/gitblit/wicket/panels/UsersPanel.java

diff --git a/src/main/java/com/gitblit/utils/MessageProcessor.java b/src/main/java/com/gitblit/utils/MessageProcessor.java
new file mode 100644 (file)
index 0000000..58493de
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2013 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gitblit.utils;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.gitblit.IStoredSettings;
+import com.gitblit.Keys;
+import com.gitblit.models.RepositoryModel;
+
+public class MessageProcessor {
+
+       private final Logger logger = LoggerFactory.getLogger(getClass());
+
+       private final IStoredSettings settings;
+
+       public MessageProcessor(IStoredSettings settings) {
+               this.settings = settings;
+       }
+
+       /**
+        * Returns an html version of the commit message with any global or
+        * repository-specific regular expression substitution applied.
+        *
+        * This method uses the preferred renderer to transform the commit message.
+        *
+        * @param repository
+        * @param text
+        * @return html version of the commit message
+        */
+       public String processCommitMessage(RepositoryModel repository, String text) {
+               switch (repository.commitMessageRenderer) {
+               case MARKDOWN:
+                       try {
+                               String prepared = processCommitMessageRegex(repository.name, text);
+                               return MarkdownUtils.transformMarkdown(prepared);
+                       } catch (Exception e) {
+                               logger.error("Failed to render commit message as markdown", e);
+                       }
+                       break;
+               default:
+                       // noop
+                       break;
+               }
+
+               return processPlainCommitMessage(repository.name, text);
+       }
+
+       /**
+        * Returns an html version of the commit message with any global or
+        * repository-specific regular expression substitution applied.
+        *
+        * This method assumes the commit message is plain text.
+        *
+        * @param repositoryName
+        * @param text
+        * @return html version of the commit message
+        */
+       public String processPlainCommitMessage(String repositoryName, String text) {
+               String html = StringUtils.escapeForHtml(text, false);
+               html = processCommitMessageRegex(repositoryName, html);
+               return StringUtils.breakLinesForHtml(html);
+
+       }
+
+       /**
+        * Apply globally or per-repository specified regex substitutions to the
+        * commit message.
+        *
+        * @param repositoryName
+        * @param text
+        * @return the processed commit message
+        */
+       protected String processCommitMessageRegex(String repositoryName, String text) {
+               Map<String, String> map = new HashMap<String, String>();
+               // global regex keys
+               if (settings.getBoolean(Keys.regex.global, false)) {
+                       for (String key : settings.getAllKeys(Keys.regex.global)) {
+                               if (!key.equals(Keys.regex.global)) {
+                                       String subKey = key.substring(key.lastIndexOf('.') + 1);
+                                       map.put(subKey, settings.getString(key, ""));
+                               }
+                       }
+               }
+
+               // repository-specific regex keys
+               List<String> keys = settings.getAllKeys(Keys.regex._ROOT + "."
+                               + repositoryName.toLowerCase());
+               for (String key : keys) {
+                       String subKey = key.substring(key.lastIndexOf('.') + 1);
+                       map.put(subKey, settings.getString(key, ""));
+               }
+
+               for (Entry<String, String> entry : map.entrySet()) {
+                       String definition = entry.getValue().trim();
+                       String[] chunks = definition.split("!!!");
+                       if (chunks.length == 2) {
+                               text = text.replaceAll(chunks[0], chunks[1]);
+                       } else {
+                               logger.warn(entry.getKey()
+                                               + " improperly formatted.  Use !!! to separate match from replacement: "
+                                               + definition);
+                       }
+               }
+               return text;
+       }
+}
index a00e2e2f5249cb18246cc6c69ebd9b46ceb6252d..51ae6481fe25fb8bbd44d3858680d286f42e1d2d 100644 (file)
@@ -21,7 +21,7 @@ import org.apache.wicket.authorization.IUnauthorizedComponentInstantiationListen
 import org.apache.wicket.authorization.strategies.page.AbstractPageAuthorizationStrategy;\r
 import org.apache.wicket.markup.html.WebPage;\r
 \r
-import com.gitblit.GitBlit;\r
+import com.gitblit.IStoredSettings;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.UserModel;\r
 import com.gitblit.wicket.pages.BasePage;\r
@@ -29,9 +29,11 @@ import com.gitblit.wicket.pages.BasePage;
 public class AuthorizationStrategy extends AbstractPageAuthorizationStrategy implements\r
                IUnauthorizedComponentInstantiationListener {\r
 \r
+       IStoredSettings settings;\r
        Class<? extends WebPage> homepageClass;\r
 \r
-       public AuthorizationStrategy(Class<? extends WebPage> homepageClass) {\r
+       public AuthorizationStrategy(IStoredSettings settings, Class<? extends WebPage> homepageClass) {\r
+               this.settings = settings;\r
                this.homepageClass = homepageClass;\r
        }\r
 \r
@@ -45,9 +47,9 @@ public class AuthorizationStrategy extends AbstractPageAuthorizationStrategy imp
                }\r
 \r
                if (BasePage.class.isAssignableFrom(pageClass)) {\r
-                       boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, true);\r
-                       boolean authenticateAdmin = GitBlit.getBoolean(Keys.web.authenticateAdminPages, true);\r
-                       boolean allowAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, true);\r
+                       boolean authenticateView = settings.getBoolean(Keys.web.authenticateViewPages, true);\r
+                       boolean authenticateAdmin = settings.getBoolean(Keys.web.authenticateAdminPages, true);\r
+                       boolean allowAdmin = settings.getBoolean(Keys.web.allowAdministration, true);\r
 \r
                        GitBlitWebSession session = GitBlitWebSession.get();\r
                        if (authenticateView && !session.isLoggedIn()) {\r
index 8cbda461453f32ef58c0aec1d9de8b7b2018ca87..1a46a1f77c1abef213d37e32909a1a1979964b9f 100644 (file)
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.gitblit.wicket;\r
-\r
-import java.util.HashMap;\r
-import java.util.Locale;\r
-import java.util.Map;\r
-\r
-import org.apache.wicket.Application;\r
-import org.apache.wicket.Request;\r
-import org.apache.wicket.Response;\r
-import org.apache.wicket.Session;\r
-import org.apache.wicket.markup.html.WebPage;\r
-import org.apache.wicket.protocol.http.WebApplication;\r
-\r
-import com.gitblit.GitBlit;\r
-import com.gitblit.Keys;\r
-import com.gitblit.utils.StringUtils;\r
-import com.gitblit.wicket.pages.ActivityPage;\r
-import com.gitblit.wicket.pages.BlamePage;\r
-import com.gitblit.wicket.pages.BlobDiffPage;\r
-import com.gitblit.wicket.pages.BlobPage;\r
-import com.gitblit.wicket.pages.BranchesPage;\r
-import com.gitblit.wicket.pages.CommitDiffPage;\r
-import com.gitblit.wicket.pages.CommitPage;\r
-import com.gitblit.wicket.pages.ComparePage;\r
-import com.gitblit.wicket.pages.DocPage;\r
-import com.gitblit.wicket.pages.DocsPage;\r
-import com.gitblit.wicket.pages.FederationRegistrationPage;\r
-import com.gitblit.wicket.pages.ForkPage;\r
-import com.gitblit.wicket.pages.ForksPage;\r
-import com.gitblit.wicket.pages.GitSearchPage;\r
-import com.gitblit.wicket.pages.GravatarProfilePage;\r
-import com.gitblit.wicket.pages.HistoryPage;\r
-import com.gitblit.wicket.pages.LogPage;\r
-import com.gitblit.wicket.pages.LogoutPage;\r
-import com.gitblit.wicket.pages.LuceneSearchPage;\r
-import com.gitblit.wicket.pages.MetricsPage;\r
-import com.gitblit.wicket.pages.MyDashboardPage;\r
-import com.gitblit.wicket.pages.OverviewPage;\r
-import com.gitblit.wicket.pages.PatchPage;\r
-import com.gitblit.wicket.pages.ProjectPage;\r
-import com.gitblit.wicket.pages.ProjectsPage;\r
-import com.gitblit.wicket.pages.RawPage;\r
-import com.gitblit.wicket.pages.ReflogPage;\r
-import com.gitblit.wicket.pages.RepositoriesPage;\r
-import com.gitblit.wicket.pages.ReviewProposalPage;\r
-import com.gitblit.wicket.pages.SummaryPage;\r
-import com.gitblit.wicket.pages.TagPage;\r
-import com.gitblit.wicket.pages.TagsPage;\r
-import com.gitblit.wicket.pages.TreePage;\r
-import com.gitblit.wicket.pages.UserPage;\r
-import com.gitblit.wicket.pages.UsersPage;\r
-\r
-public class GitBlitWebApp extends WebApplication {\r
-\r
-       private final Class<? extends WebPage> homePageClass = MyDashboardPage.class;\r
-\r
-       private final Map<String, CacheControl> cacheablePages = new HashMap<String, CacheControl>();\r
-\r
-       @Override\r
-       public void init() {\r
-               super.init();\r
-\r
-               // Setup page authorization mechanism\r
-               boolean useAuthentication = GitBlit.getBoolean(Keys.web.authenticateViewPages, false)\r
-                               || GitBlit.getBoolean(Keys.web.authenticateAdminPages, false);\r
-               if (useAuthentication) {\r
-                       AuthorizationStrategy authStrategy = new AuthorizationStrategy(homePageClass);\r
-                       getSecuritySettings().setAuthorizationStrategy(authStrategy);\r
-                       getSecuritySettings().setUnauthorizedComponentInstantiationListener(authStrategy);\r
-               }\r
-\r
-               // Grab Browser info (like timezone, etc)\r
-               if (GitBlit.getBoolean(Keys.web.useClientTimezone, false)) {\r
-                       getRequestCycleSettings().setGatherExtendedBrowserInfo(true);\r
-               }\r
-\r
-               // configure the resource cache duration to 90 days for deployment\r
-               if (!GitBlit.isDebugMode()) {\r
-                       getResourceSettings().setDefaultCacheDuration(90 * 86400);\r
-               }\r
-\r
-               // setup the standard gitweb-ish urls\r
-               mount("/repositories", RepositoriesPage.class);\r
-               mount("/overview", OverviewPage.class, "r", "h");\r
-               mount("/summary", SummaryPage.class, "r");\r
-               mount("/reflog", ReflogPage.class, "r", "h");\r
-               mount("/commits", LogPage.class, "r", "h");\r
-               mount("/log", LogPage.class, "r", "h");\r
-               mount("/tags", TagsPage.class, "r");\r
-               mount("/branches", BranchesPage.class, "r");\r
-               mount("/commit", CommitPage.class, "r", "h");\r
-               mount("/tag", TagPage.class, "r", "h");\r
-               mount("/tree", TreePage.class, "r", "h", "f");\r
-               mount("/blob", BlobPage.class, "r", "h", "f");\r
-               mount("/raw", RawPage.class, "r", "h", "f");\r
-               mount("/blobdiff", BlobDiffPage.class, "r", "h", "f");\r
-               mount("/commitdiff", CommitDiffPage.class, "r", "h");\r
-               mount("/compare", ComparePage.class, "r", "h");\r
-               mount("/patch", PatchPage.class, "r", "h", "f");\r
-               mount("/history", HistoryPage.class, "r", "h", "f");\r
-               mount("/search", GitSearchPage.class);\r
-               mount("/metrics", MetricsPage.class, "r");\r
-               mount("/blame", BlamePage.class, "r", "h", "f");\r
-               mount("/users", UsersPage.class);\r
-               mount("/logout", LogoutPage.class);\r
-\r
-               // setup the markup document urls\r
-               mount("/docs", DocsPage.class, "r");\r
-               mount("/doc", DocPage.class, "r", "h", "f");\r
-\r
-               // federation urls\r
-               mount("/proposal", ReviewProposalPage.class, "t");\r
-               mount("/registration", FederationRegistrationPage.class, "u", "n");\r
-\r
-               mount("/activity", ActivityPage.class, "r", "h");\r
-               mount("/gravatar", GravatarProfilePage.class, "h");\r
-               mount("/lucene", LuceneSearchPage.class);\r
-               mount("/project", ProjectPage.class, "p");\r
-               mount("/projects", ProjectsPage.class);\r
-               mount("/user", UserPage.class, "user");\r
-               mount("/forks", ForksPage.class, "r");\r
-               mount("/fork", ForkPage.class, "r");\r
-               \r
-               getMarkupSettings().setDefaultMarkupEncoding("UTF-8");\r
-       }\r
-\r
-       private void mount(String location, Class<? extends WebPage> clazz, String... parameters) {\r
-               if (parameters == null) {\r
-                       parameters = new String[] {};\r
-               }\r
-               if (!GitBlit.getBoolean(Keys.web.mountParameters, true)) {\r
-                       parameters = new String[] {};\r
-               }\r
-               mount(new GitblitParamUrlCodingStrategy(location, clazz, parameters));\r
-\r
-               // map the mount point to the cache control definition\r
-               if (clazz.isAnnotationPresent(CacheControl.class)) {\r
-                       CacheControl cacheControl = clazz.getAnnotation(CacheControl.class);\r
-                       cacheablePages.put(location.substring(1), cacheControl);\r
-               }\r
-       }\r
-\r
-       @Override\r
-       public Class<? extends WebPage> getHomePage() {\r
-               return homePageClass;\r
-       }\r
-\r
-       public boolean isCacheablePage(String mountPoint) {\r
-               return cacheablePages.containsKey(mountPoint);\r
-       }\r
-\r
-       public CacheControl getCacheControl(String mountPoint) {\r
-               return cacheablePages.get(mountPoint);\r
-       }\r
-\r
-       @Override\r
-       public final Session newSession(Request request, Response response) {\r
-               GitBlitWebSession gitBlitWebSession = new GitBlitWebSession(request);\r
-\r
-               String forcedLocale = GitBlit.getString(Keys.web.forceDefaultLocale, null);\r
-               if (!StringUtils.isEmpty(forcedLocale)) {\r
-                       gitBlitWebSession.setLocale(new Locale(forcedLocale));\r
-               }\r
-               return gitBlitWebSession;\r
-       }\r
-\r
-       @Override\r
-       public final String getConfigurationType() {\r
-               if (GitBlit.isDebugMode()) {\r
-                       return Application.DEVELOPMENT;\r
-               }\r
-               return Application.DEPLOYMENT;\r
-       }\r
-\r
-       public static GitBlitWebApp get() {\r
-               return (GitBlitWebApp) WebApplication.get();\r
-       }\r
-}\r
+/*
+ * Copyright 2011 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gitblit.wicket;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.Request;
+import org.apache.wicket.Response;
+import org.apache.wicket.Session;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.protocol.http.WebApplication;
+
+import com.gitblit.GitBlit;
+import com.gitblit.IStoredSettings;
+import com.gitblit.Keys;
+import com.gitblit.utils.StringUtils;
+import com.gitblit.wicket.pages.ActivityPage;
+import com.gitblit.wicket.pages.BlamePage;
+import com.gitblit.wicket.pages.BlobDiffPage;
+import com.gitblit.wicket.pages.BlobPage;
+import com.gitblit.wicket.pages.BranchesPage;
+import com.gitblit.wicket.pages.CommitDiffPage;
+import com.gitblit.wicket.pages.CommitPage;
+import com.gitblit.wicket.pages.ComparePage;
+import com.gitblit.wicket.pages.DocPage;
+import com.gitblit.wicket.pages.DocsPage;
+import com.gitblit.wicket.pages.FederationRegistrationPage;
+import com.gitblit.wicket.pages.ForkPage;
+import com.gitblit.wicket.pages.ForksPage;
+import com.gitblit.wicket.pages.GitSearchPage;
+import com.gitblit.wicket.pages.GravatarProfilePage;
+import com.gitblit.wicket.pages.HistoryPage;
+import com.gitblit.wicket.pages.LogPage;
+import com.gitblit.wicket.pages.LogoutPage;
+import com.gitblit.wicket.pages.LuceneSearchPage;
+import com.gitblit.wicket.pages.MetricsPage;
+import com.gitblit.wicket.pages.MyDashboardPage;
+import com.gitblit.wicket.pages.OverviewPage;
+import com.gitblit.wicket.pages.PatchPage;
+import com.gitblit.wicket.pages.ProjectPage;
+import com.gitblit.wicket.pages.ProjectsPage;
+import com.gitblit.wicket.pages.RawPage;
+import com.gitblit.wicket.pages.ReflogPage;
+import com.gitblit.wicket.pages.RepositoriesPage;
+import com.gitblit.wicket.pages.ReviewProposalPage;
+import com.gitblit.wicket.pages.SummaryPage;
+import com.gitblit.wicket.pages.TagPage;
+import com.gitblit.wicket.pages.TagsPage;
+import com.gitblit.wicket.pages.TreePage;
+import com.gitblit.wicket.pages.UserPage;
+import com.gitblit.wicket.pages.UsersPage;
+
+public class GitBlitWebApp extends WebApplication {
+
+       private final Class<? extends WebPage> homePageClass = MyDashboardPage.class;
+
+       private final Map<String, CacheControl> cacheablePages = new HashMap<String, CacheControl>();
+
+       private IStoredSettings settings;
+
+       @Override
+       public void init() {
+               super.init();
+
+               settings = GitBlit.getSettings();
+
+               // Setup page authorization mechanism
+               boolean useAuthentication = settings.getBoolean(Keys.web.authenticateViewPages, false)
+                               || settings.getBoolean(Keys.web.authenticateAdminPages, false);
+               if (useAuthentication) {
+                       AuthorizationStrategy authStrategy = new AuthorizationStrategy(settings, homePageClass);
+                       getSecuritySettings().setAuthorizationStrategy(authStrategy);
+                       getSecuritySettings().setUnauthorizedComponentInstantiationListener(authStrategy);
+               }
+
+               // Grab Browser info (like timezone, etc)
+               if (settings.getBoolean(Keys.web.useClientTimezone, false)) {
+                       getRequestCycleSettings().setGatherExtendedBrowserInfo(true);
+               }
+
+               // configure the resource cache duration to 90 days for deployment
+               if (!isDebugMode()) {
+                       getResourceSettings().setDefaultCacheDuration(90 * 86400);
+               }
+
+               // setup the standard gitweb-ish urls
+               mount("/repositories", RepositoriesPage.class);
+               mount("/overview", OverviewPage.class, "r", "h");
+               mount("/summary", SummaryPage.class, "r");
+               mount("/reflog", ReflogPage.class, "r", "h");
+               mount("/commits", LogPage.class, "r", "h");
+               mount("/log", LogPage.class, "r", "h");
+               mount("/tags", TagsPage.class, "r");
+               mount("/branches", BranchesPage.class, "r");
+               mount("/commit", CommitPage.class, "r", "h");
+               mount("/tag", TagPage.class, "r", "h");
+               mount("/tree", TreePage.class, "r", "h", "f");
+               mount("/blob", BlobPage.class, "r", "h", "f");
+               mount("/raw", RawPage.class, "r", "h", "f");
+               mount("/blobdiff", BlobDiffPage.class, "r", "h", "f");
+               mount("/commitdiff", CommitDiffPage.class, "r", "h");
+               mount("/compare", ComparePage.class, "r", "h");
+               mount("/patch", PatchPage.class, "r", "h", "f");
+               mount("/history", HistoryPage.class, "r", "h", "f");
+               mount("/search", GitSearchPage.class);
+               mount("/metrics", MetricsPage.class, "r");
+               mount("/blame", BlamePage.class, "r", "h", "f");
+               mount("/users", UsersPage.class);
+               mount("/logout", LogoutPage.class);
+
+               // setup the markup document urls
+               mount("/docs", DocsPage.class, "r");
+               mount("/doc", DocPage.class, "r", "h", "f");
+
+               // federation urls
+               mount("/proposal", ReviewProposalPage.class, "t");
+               mount("/registration", FederationRegistrationPage.class, "u", "n");
+
+               mount("/activity", ActivityPage.class, "r", "h");
+               mount("/gravatar", GravatarProfilePage.class, "h");
+               mount("/lucene", LuceneSearchPage.class);
+               mount("/project", ProjectPage.class, "p");
+               mount("/projects", ProjectsPage.class);
+               mount("/user", UserPage.class, "user");
+               mount("/forks", ForksPage.class, "r");
+               mount("/fork", ForkPage.class, "r");
+               
+               getMarkupSettings().setDefaultMarkupEncoding("UTF-8");
+               super.init();
+       }
+
+       private void mount(String location, Class<? extends WebPage> clazz, String... parameters) {
+               if (parameters == null) {
+                       parameters = new String[] {};
+               }
+               if (!settings.getBoolean(Keys.web.mountParameters, true)) {
+                       parameters = new String[] {};
+               }
+               mount(new GitblitParamUrlCodingStrategy(settings, location, clazz, parameters));
+
+               // map the mount point to the cache control definition
+               if (clazz.isAnnotationPresent(CacheControl.class)) {
+                       CacheControl cacheControl = clazz.getAnnotation(CacheControl.class);
+                       cacheablePages.put(location.substring(1), cacheControl);
+               }
+       }
+
+       @Override
+       public Class<? extends WebPage> getHomePage() {
+               return homePageClass;
+       }
+
+       public boolean isCacheablePage(String mountPoint) {
+               return cacheablePages.containsKey(mountPoint);
+       }
+
+       public CacheControl getCacheControl(String mountPoint) {
+               return cacheablePages.get(mountPoint);
+       }
+
+       @Override
+       public final Session newSession(Request request, Response response) {
+               GitBlitWebSession gitBlitWebSession = new GitBlitWebSession(request);
+
+               String forcedLocale = settings.getString(Keys.web.forceDefaultLocale, null);
+               if (!StringUtils.isEmpty(forcedLocale)) {
+                       gitBlitWebSession.setLocale(new Locale(forcedLocale));
+               }
+               return gitBlitWebSession;
+       }
+
+       public IStoredSettings settings() {
+               return settings;
+       }
+
+       /**
+        * Is Gitblit running in debug mode?
+        *
+        * @return true if Gitblit is running in debug mode
+        */
+       public boolean isDebugMode() {
+               return GitBlit.isDebugMode();
+       }
+
+       /*
+        * These methods look strange... and they are... but they are the first
+        * step towards modularization across multiple commits.
+        */
+       public Date getBootDate() {
+               return GitBlit.getBootDate();
+       }
+
+       public Date getLastActivityDate() {
+               return GitBlit.getLastActivityDate();
+       }
+
+       public GitBlit runtime() {
+               return GitBlit.self();
+       }
+
+       public GitBlit mail() {
+               return GitBlit.self();
+       }
+
+       public GitBlit users() {
+               return GitBlit.self();
+       }
+
+       public GitBlit session() {
+               return GitBlit.self();
+       }
+
+       public GitBlit repositories() {
+               return GitBlit.self();
+       }
+
+       public GitBlit projects() {
+               return GitBlit.self();
+       }
+
+       public GitBlit federation() {
+               return GitBlit.self();
+       }
+
+       public GitBlit gitblit() {
+               return GitBlit.self();
+       }
+
+       public TimeZone getTimezone() {
+               return GitBlit.getTimezone();
+       }
+
+       @Override
+       public final String getConfigurationType() {
+               if (isDebugMode()) {
+                       return Application.DEVELOPMENT;
+               }
+               return Application.DEPLOYMENT;
+       }
+
+       public static GitBlitWebApp get() {
+               return (GitBlitWebApp) WebApplication.get();
+       }
+}
index 2d65d37b5828983c5518f9f1e935a3f713d372b2..4f67a4ab4dff93dd4f795ec419a0eba779fa9658 100644 (file)
@@ -25,7 +25,7 @@ import org.apache.wicket.request.target.coding.MixedParamUrlCodingStrategy;
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
-import com.gitblit.GitBlit;\r
+import com.gitblit.IStoredSettings;\r
 import com.gitblit.Keys;\r
 \r
 /**\r
@@ -42,6 +42,8 @@ public class GitblitParamUrlCodingStrategy extends MixedParamUrlCodingStrategy {
 \r
        private Logger logger = LoggerFactory.getLogger(GitblitParamUrlCodingStrategy.class);\r
 \r
+       private IStoredSettings settings;\r
+\r
        /**\r
         * Construct.\r
         *\r
@@ -53,9 +55,13 @@ public class GitblitParamUrlCodingStrategy extends MixedParamUrlCodingStrategy {
         * @param parameterNames\r
         *            the parameter names (not null)\r
         */\r
-       public <C extends Page> GitblitParamUrlCodingStrategy(String mountPath,\r
+       public <C extends Page> GitblitParamUrlCodingStrategy(\r
+                       IStoredSettings settings,\r
+                       String mountPath,\r
                        Class<C> bookmarkablePageClass, String[] parameterNames) {\r
+\r
                super(mountPath, bookmarkablePageClass, parameterNames);\r
+               this.settings = settings;\r
        }\r
 \r
        /**\r
@@ -67,7 +73,7 @@ public class GitblitParamUrlCodingStrategy extends MixedParamUrlCodingStrategy {
         */\r
        @Override\r
        protected String urlEncodePathComponent(String string) {\r
-               char altChar = GitBlit.getChar(Keys.web.forwardSlashCharacter, '/');\r
+               char altChar = settings.getChar(Keys.web.forwardSlashCharacter, '/');\r
                if (altChar != '/') {\r
                        string = string.replace('/', altChar);\r
                }\r
@@ -83,7 +89,7 @@ public class GitblitParamUrlCodingStrategy extends MixedParamUrlCodingStrategy {
         */\r
        @Override\r
        protected String urlDecodePathComponent(String value) {\r
-               char altChar = GitBlit.getChar(Keys.web.forwardSlashCharacter, '/');\r
+               char altChar = settings.getChar(Keys.web.forwardSlashCharacter, '/');\r
                if (altChar != '/') {\r
                        value = value.replace(altChar, '/');\r
                }\r
index 6e3d932f777a54955ef317e3e5139a6554367e78..8e119da838c3844a5cf8f0710b15f1f154c20579 100644 (file)
@@ -44,7 +44,6 @@ import org.wicketstuff.googlecharts.IChartData;
 import com.gitblit.Constants;\r
 import com.gitblit.Constants.AccessPermission;\r
 import com.gitblit.Constants.FederationPullStatus;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.FederationModel;\r
 import com.gitblit.models.Metric;\r
@@ -189,7 +188,7 @@ public class WicketUtils {
                        return newImage(wicketId, "file_settings_16x16.png");\r
                }\r
 \r
-               MarkupProcessor processor = new MarkupProcessor(GitBlit.getSettings());\r
+               MarkupProcessor processor = new MarkupProcessor(GitBlitWebApp.get().settings());\r
                String ext = StringUtils.getFileExtension(filename).toLowerCase();\r
                if (processor.getMarkupExtensions().contains(ext)) {\r
                        return newImage(wicketId, "file_world_16x16.png");\r
@@ -510,10 +509,10 @@ public class WicketUtils {
        }\r
 \r
        public static Label createDateLabel(String wicketId, Date date, TimeZone timeZone, TimeUtils timeUtils, boolean setCss) {\r
-               String format = GitBlit.getString(Keys.web.datestampShortFormat, "MM/dd/yy");\r
+               String format = GitBlitWebApp.get().settings().getString(Keys.web.datestampShortFormat, "MM/dd/yy");\r
                DateFormat df = new SimpleDateFormat(format);\r
                if (timeZone == null) {\r
-                       timeZone = GitBlit.getTimezone();\r
+                       timeZone = GitBlitWebApp.get().getTimezone();\r
                }\r
                df.setTimeZone(timeZone);\r
                String dateString;\r
@@ -543,10 +542,10 @@ public class WicketUtils {
        }\r
 \r
        public static Label createTimeLabel(String wicketId, Date date, TimeZone timeZone, TimeUtils timeUtils) {\r
-               String format = GitBlit.getString(Keys.web.timeFormat, "HH:mm");\r
+               String format = GitBlitWebApp.get().settings().getString(Keys.web.timeFormat, "HH:mm");\r
                DateFormat df = new SimpleDateFormat(format);\r
                if (timeZone == null) {\r
-                       timeZone = GitBlit.getTimezone();\r
+                       timeZone = GitBlitWebApp.get().getTimezone();\r
                }\r
                df.setTimeZone(timeZone);\r
                String timeString;\r
@@ -564,10 +563,10 @@ public class WicketUtils {
        }\r
 \r
        public static Label createDatestampLabel(String wicketId, Date date, TimeZone timeZone, TimeUtils timeUtils) {\r
-               String format = GitBlit.getString(Keys.web.datestampLongFormat, "EEEE, MMMM d, yyyy");\r
+               String format = GitBlitWebApp.get().settings().getString(Keys.web.datestampLongFormat, "EEEE, MMMM d, yyyy");\r
                DateFormat df = new SimpleDateFormat(format);\r
                if (timeZone == null) {\r
-                       timeZone = GitBlit.getTimezone();\r
+                       timeZone = GitBlitWebApp.get().getTimezone();\r
                }\r
                df.setTimeZone(timeZone);\r
                String dateString;\r
@@ -598,11 +597,11 @@ public class WicketUtils {
        }\r
 \r
        public static Label createTimestampLabel(String wicketId, Date date, TimeZone timeZone, TimeUtils timeUtils) {\r
-               String format = GitBlit.getString(Keys.web.datetimestampLongFormat,\r
+               String format = GitBlitWebApp.get().settings().getString(Keys.web.datetimestampLongFormat,\r
                                "EEEE, MMMM d, yyyy HH:mm Z");\r
                DateFormat df = new SimpleDateFormat(format);\r
                if (timeZone == null) {\r
-                       timeZone = GitBlit.getTimezone();\r
+                       timeZone = GitBlitWebApp.get().getTimezone();\r
                }\r
                df.setTimeZone(timeZone);\r
                String dateString;\r
index 99992eaeeddd27e0c6028ea00ba74bf1c5f96d46..5e7332f5a7047b41265736d7df78dbbe4b3ef783 100644 (file)
@@ -29,7 +29,6 @@ import org.apache.wicket.behavior.HeaderContributor;
 import org.apache.wicket.markup.html.basic.Label;\r
 import org.apache.wicket.markup.html.panel.Fragment;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.Activity;\r
 import com.gitblit.models.Metric;\r
@@ -66,7 +65,7 @@ public class ActivityPage extends RootPage {
                // parameters\r
                int daysBack = WicketUtils.getDaysBack(params);\r
                if (daysBack < 1) {\r
-                       daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);\r
+                       daysBack = app().settings().getInteger(Keys.web.activityDuration, 7);\r
                }\r
                String objectId = WicketUtils.getObject(params);\r
 \r
@@ -113,7 +112,7 @@ public class ActivityPage extends RootPage {
                                        daysBack, totalCommits, totalAuthors)));\r
 \r
                        // create the activity charts\r
-                       if (GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {\r
+                       if (app().settings().getBoolean(Keys.web.generateActivityGraph, true)) {\r
                                GoogleCharts charts = createCharts(recentActivity);\r
                                add(new HeaderContributor(charts));\r
                                add(new Fragment("chartsPanel", "chartsFragment", this));\r
@@ -137,7 +136,7 @@ public class ActivityPage extends RootPage {
                                ActivityPage.class);\r
 \r
                PageParameters currentParameters = getPageParameters();\r
-               int daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);\r
+               int daysBack = app().settings().getInteger(Keys.web.activityDuration, 7);\r
                if (currentParameters != null && !currentParameters.containsKey("db")) {\r
                        currentParameters.put("db", daysBack);\r
                }\r
index 9bae378364e5a14869d3610392d0c20a3f4bbb1d..647a9388e128931a6a453818968acc0761cc78f0 100644 (file)
@@ -52,7 +52,6 @@ import com.gitblit.Constants.AccessPermission;
 import com.gitblit.Constants.AccessRestrictionType;\r
 import com.gitblit.Constants.AuthorizationControl;\r
 import com.gitblit.Constants.FederationStrategy;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.ProjectModel;\r
 import com.gitblit.models.TeamModel;\r
@@ -83,7 +82,7 @@ public abstract class BasePage extends SessionPage {
        }\r
 \r
        private void customizeHeader() {\r
-               if (GitBlit.getBoolean(Keys.web.useResponsiveLayout, true)) {\r
+               if (app().settings().getBoolean(Keys.web.useResponsiveLayout, true)) {\r
                        add(CSSPackageResource.getHeaderContribution("bootstrap/css/bootstrap-responsive.css"));\r
                }\r
        }\r
@@ -121,7 +120,7 @@ public abstract class BasePage extends SessionPage {
 \r
        @Override\r
        protected void onBeforeRender() {\r
-               if (GitBlit.isDebugMode()) {\r
+               if (app().isDebugMode()) {\r
                        // strip Wicket tags in debug mode for jQuery DOM traversal\r
                        Application.get().getMarkupSettings().setStripWicketTags(true);\r
                }\r
@@ -130,7 +129,7 @@ public abstract class BasePage extends SessionPage {
 \r
        @Override\r
        protected void onAfterRender() {\r
-               if (GitBlit.isDebugMode()) {\r
+               if (app().isDebugMode()) {\r
                        // restore Wicket debug tags\r
                        Application.get().getMarkupSettings().setStripWicketTags(false);\r
                }\r
@@ -141,8 +140,8 @@ public abstract class BasePage extends SessionPage {
        protected void setHeaders(WebResponse response) {\r
                // set canonical link as http header for SEO (issue-304)\r
                // https://support.google.com/webmasters/answer/139394?hl=en\r
-               response.setHeader("Link" ,MessageFormat.format("<{0}>; rel=\"canonical\"", getCanonicalUrl()));\r
-               int expires = GitBlit.getInteger(Keys.web.pageCacheExpires, 0);\r
+               response.setHeader("Link"MessageFormat.format("<{0}>; rel=\"canonical\"", getCanonicalUrl()));\r
+               int expires = app().settings().getInteger(Keys.web.pageCacheExpires, 0);\r
                if (expires > 0) {\r
                        // pages are personalized for the authenticated user so they must be\r
                        // marked private to prohibit proxy servers from caching them\r
@@ -164,10 +163,10 @@ public abstract class BasePage extends SessionPage {
                        CacheControl cacheControl = getClass().getAnnotation(CacheControl.class);\r
                        switch (cacheControl.value()) {\r
                        case ACTIVITY:\r
-                               setLastModified(GitBlit.getLastActivityDate());\r
+                               setLastModified(app().getLastActivityDate());\r
                                break;\r
                        case BOOT:\r
-                               setLastModified(GitBlit.getBootDate());\r
+                               setLastModified(app().getBootDate());\r
                                break;\r
                        case NONE:\r
                                break;\r
@@ -188,21 +187,21 @@ public abstract class BasePage extends SessionPage {
                        return;\r
                }\r
 \r
-               if (when.before(GitBlit.getBootDate())) {\r
+               if (when.before(app().getBootDate())) {\r
                        // last-modified can not be before the Gitblit boot date\r
                        // this helps ensure that pages are properly refreshed after a\r
                        // server config change\r
-                       when = GitBlit.getBootDate();\r
+                       when = app().getBootDate();\r
                }\r
 \r
-               int expires = GitBlit.getInteger(Keys.web.pageCacheExpires, 0);\r
+               int expires = app().settings().getInteger(Keys.web.pageCacheExpires, 0);\r
                WebResponse response = (WebResponse) getResponse();\r
                response.setLastModifiedTime(Time.valueOf(when));\r
                response.setDateHeader("Expires", System.currentTimeMillis() + Duration.minutes(expires).getMilliseconds());\r
        }\r
 \r
        protected void setupPage(String repositoryName, String pageName) {\r
-               String siteName = GitBlit.getString(Keys.web.siteName, Constants.NAME);\r
+               String siteName = app().settings().getString(Keys.web.siteName, Constants.NAME);\r
                if (StringUtils.isEmpty(siteName)) {\r
                        siteName = Constants.NAME;\r
                }\r
@@ -212,16 +211,16 @@ public abstract class BasePage extends SessionPage {
                        add(new Label("title", siteName));\r
                }\r
 \r
-               String rootLinkUrl = GitBlit.getString(Keys.web.rootLink, urlFor(GitBlitWebApp.get().getHomePage(), null).toString());\r
+               String rootLinkUrl = app().settings().getString(Keys.web.rootLink, urlFor(GitBlitWebApp.get().getHomePage(), null).toString());\r
                ExternalLink rootLink = new ExternalLink("rootLink", rootLinkUrl);\r
-               WicketUtils.setHtmlTooltip(rootLink, GitBlit.getString(Keys.web.siteName, Constants.NAME));\r
+               WicketUtils.setHtmlTooltip(rootLink, app().settings().getString(Keys.web.siteName, Constants.NAME));\r
                add(rootLink);\r
 \r
                // Feedback panel for info, warning, and non-fatal error messages\r
                add(new FeedbackPanel("feedback"));\r
 \r
                add(new Label("gbVersion", "v" + Constants.getVersion()));\r
-               if (GitBlit.getBoolean(Keys.web.aggressiveHeapManagement, false)) {\r
+               if (app().settings().getBoolean(Keys.web.aggressiveHeapManagement, false)) {\r
                        System.gc();\r
                }\r
        }\r
@@ -314,8 +313,8 @@ public abstract class BasePage extends SessionPage {
        }\r
 \r
        protected TimeZone getTimeZone() {\r
-               return GitBlit.getBoolean(Keys.web.useClientTimezone, false) ? GitBlitWebSession.get()\r
-                               .getTimezone() : GitBlit.getTimezone();\r
+               return app().settings().getBoolean(Keys.web.useClientTimezone, false) ? GitBlitWebSession.get()\r
+                               .getTimezone() : app().getTimezone();\r
        }\r
 \r
        protected String getServerName() {\r
@@ -326,7 +325,7 @@ public abstract class BasePage extends SessionPage {
 \r
        protected List<ProjectModel> getProjectModels() {\r
                final UserModel user = GitBlitWebSession.get().getUser();\r
-               List<ProjectModel> projects = GitBlit.self().getProjectModels(user, true);\r
+               List<ProjectModel> projects = app().projects().getProjectModels(user, true);\r
                return projects;\r
        }\r
 \r
@@ -339,7 +338,7 @@ public abstract class BasePage extends SessionPage {
                String regex = WicketUtils.getRegEx(params);\r
                String team = WicketUtils.getTeam(params);\r
                int daysBack = params.getInt("db", 0);\r
-               int maxDaysBack = GitBlit.getInteger(Keys.web.activityDurationMaximum, 30);\r
+               int maxDaysBack = app().settings().getInteger(Keys.web.activityDurationMaximum, 30);\r
 \r
                List<ProjectModel> availableModels = getProjectModels();\r
                Set<ProjectModel> models = new HashSet<ProjectModel>();\r
@@ -363,7 +362,7 @@ public abstract class BasePage extends SessionPage {
                        // need TeamModels first\r
                        List<TeamModel> teamModels = new ArrayList<TeamModel>();\r
                        for (String name : teams) {\r
-                               TeamModel teamModel = GitBlit.self().getTeamModel(name);\r
+                               TeamModel teamModel = app().users().getTeamModel(name);\r
                                if (teamModel != null) {\r
                                        teamModels.add(teamModel);\r
                                }\r
index 9f00d2127b5e51afab0894b9a68108b2dc8461e1..52682639395213e5f57c2286a5eb4921ce6198f7 100644 (file)
@@ -30,7 +30,6 @@ import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.lib.ObjectId;\r
 import org.eclipse.jgit.revwalk.RevCommit;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.AnnotatedLine;\r
 import com.gitblit.models.PathModel;\r
@@ -71,7 +70,7 @@ public class BlamePage extends RepositoryPage {
 \r
                add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, blobPath, objectId));\r
 \r
-               String format = GitBlit.getString(Keys.web.datetimestampLongFormat,\r
+               String format = app().settings().getString(Keys.web.datetimestampLongFormat,\r
                                "EEEE, MMMM d, yyyy HH:mm Z");\r
                final DateFormat df = new SimpleDateFormat(format);\r
                df.setTimeZone(getTimeZone());\r
index 56ad5b96329beb7035c9ab92620946035cfeb8e9..c4eca10abce4dfbde3e3118c1beeb14de5466cc9 100644 (file)
@@ -28,7 +28,6 @@ import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.lib.Repository;\r
 import org.eclipse.jgit.revwalk.RevCommit;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.StringUtils;\r
@@ -50,7 +49,7 @@ public class BlobPage extends RepositoryPage {
 \r
                Repository r = getRepository();\r
                final String blobPath = WicketUtils.getPath(params);\r
-               String [] encodings = GitBlit.getEncodings();\r
+               String [] encodings = getEncodings();\r
 \r
                if (StringUtils.isEmpty(blobPath)) {\r
                        // blob by objectid\r
@@ -75,7 +74,7 @@ public class BlobPage extends RepositoryPage {
                        }\r
 \r
                        // see if we should redirect to the doc page\r
-                       MarkupProcessor processor = new MarkupProcessor(GitBlit.getSettings());\r
+                       MarkupProcessor processor = new MarkupProcessor(app().settings());\r
                        for (String ext : processor.getMarkupExtensions()) {\r
                                if (ext.equals(extension)) {\r
                                        setResponsePage(DocPage.class, params);\r
@@ -102,13 +101,13 @@ public class BlobPage extends RepositoryPage {
 \r
                        // Map the extensions to types\r
                        Map<String, Integer> map = new HashMap<String, Integer>();\r
-                       for (String ext : GitBlit.getStrings(Keys.web.prettyPrintExtensions)) {\r
+                       for (String ext : app().settings().getStrings(Keys.web.prettyPrintExtensions)) {\r
                                map.put(ext.toLowerCase(), 1);\r
                        }\r
-                       for (String ext : GitBlit.getStrings(Keys.web.imageExtensions)) {\r
+                       for (String ext : app().settings().getStrings(Keys.web.imageExtensions)) {\r
                                map.put(ext.toLowerCase(), 2);\r
                        }\r
-                       for (String ext : GitBlit.getStrings(Keys.web.binaryExtensions)) {\r
+                       for (String ext : app().settings().getStrings(Keys.web.binaryExtensions)) {\r
                                map.put(ext.toLowerCase(), 3);\r
                        }\r
 \r
index 302de0dabd3bf75031461df7c5989c05ba7ccfbb..3e308f1b8a580e21a48d4ace3be3979ddcac7f42 100644 (file)
@@ -25,7 +25,6 @@ import org.apache.wicket.model.IModel;
 import org.apache.wicket.model.Model;\r
 import org.apache.wicket.protocol.http.WebResponse;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.GitBlitException;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.UserModel;\r
@@ -45,16 +44,16 @@ public class ChangePasswordPage extends RootSubPage {
                        throw new RestartResponseException(getApplication().getHomePage());\r
                }\r
 \r
-               if (!GitBlit.getBoolean(Keys.web.authenticateAdminPages, true)\r
-                               && !GitBlit.getBoolean(Keys.web.authenticateViewPages, false)) {\r
+               if (!app().settings().getBoolean(Keys.web.authenticateAdminPages, true)\r
+                               && !app().settings().getBoolean(Keys.web.authenticateViewPages, false)) {\r
                        // no authentication enabled\r
                        throw new RestartResponseException(getApplication().getHomePage());\r
                }\r
 \r
                UserModel user = GitBlitWebSession.get().getUser();\r
-               if (!GitBlit.self().supportsCredentialChanges(user)) {\r
+               if (!app().users().supportsCredentialChanges(user)) {\r
                        error(MessageFormat.format(getString("gb.userServiceDoesNotPermitPasswordChanges"),\r
-                                       GitBlit.getString(Keys.realm.userService, "${baseFolder}/users.conf")), true);\r
+                                       app().settings().getString(Keys.realm.userService, "${baseFolder}/users.conf")), true);\r
                }\r
 \r
                setupPage(getString("gb.changePassword"), user.username);\r
@@ -74,7 +73,7 @@ public class ChangePasswordPage extends RootSubPage {
                                }\r
 \r
                                // ensure password satisfies minimum length requirement\r
-                               int minLength = GitBlit.getInteger(Keys.realm.minPasswordLength, 5);\r
+                               int minLength = app().settings().getInteger(Keys.realm.minPasswordLength, 5);\r
                                if (minLength < 4) {\r
                                        minLength = 4;\r
                                }\r
@@ -86,7 +85,7 @@ public class ChangePasswordPage extends RootSubPage {
                                UserModel user = GitBlitWebSession.get().getUser();\r
 \r
                                // convert to MD5 digest, if appropriate\r
-                               String type = GitBlit.getString(Keys.realm.passwordStorage, "md5");\r
+                               String type = app().settings().getString(Keys.realm.passwordStorage, "md5");\r
                                if (type.equalsIgnoreCase("md5")) {\r
                                        // store MD5 digest of password\r
                                        password = StringUtils.MD5_TYPE + StringUtils.getMD5(password);\r
@@ -98,10 +97,10 @@ public class ChangePasswordPage extends RootSubPage {
 \r
                                user.password = password;\r
                                try {\r
-                                       GitBlit.self().updateUserModel(user.username, user, false);\r
-                                       if (GitBlit.getBoolean(Keys.web.allowCookieAuthentication, false)) {\r
+                                       app().users().updateUserModel(user.username, user, false);\r
+                                       if (app().settings().getBoolean(Keys.web.allowCookieAuthentication, false)) {\r
                                                WebResponse response = (WebResponse) getRequestCycle().getResponse();\r
-                                               GitBlit.self().setCookie(response, user);\r
+                                               app().session().setCookie(response, user);\r
                                        }\r
                                } catch (GitBlitException e) {\r
                                        error(e.getMessage());\r
index 468fb667dcd01b7f5d028b5318aae018d5296e10..5d14bfecd511689ba8a175eaaba49d13492ff1f3 100644 (file)
@@ -31,7 +31,6 @@ import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.revwalk.RevCommit;
 
 import com.gitblit.Constants;
-import com.gitblit.GitBlit;
 import com.gitblit.models.GitNote;
 import com.gitblit.models.PathModel.PathChangeModel;
 import com.gitblit.models.SubmoduleModel;
@@ -108,7 +107,7 @@ public class CommitDiffPage extends RepositoryPage {
                                item.add(new GravatarImage("noteAuthorAvatar", entry.notesRef.getAuthorIdent()));
                                item.add(WicketUtils.createTimestampLabel("authorDate", entry.notesRef
                                                .getAuthorIdent().getWhen(), getTimeZone(), getTimeUtils()));
-                               item.add(new Label("noteContent", GitBlit.self().processPlainCommitMessage(repositoryName,
+                               item.add(new Label("noteContent", messageProcessor().processPlainCommitMessage(repositoryName,
                                                entry.content)).setEscapeModelStrings(false));
                        }
                };
index 1772f3af6a0cd82540de1614d3943c638314b7af..594223321074e54ed8e122a54c8b9538fba40e79 100644 (file)
@@ -32,7 +32,6 @@ import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.revwalk.RevCommit;\r
 \r
 import com.gitblit.Constants;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.models.GitNote;\r
 import com.gitblit.models.PathModel.PathChangeModel;\r
 import com.gitblit.models.SubmoduleModel;\r
@@ -136,7 +135,7 @@ public class CommitPage extends RepositoryPage {
                                item.add(new GravatarImage("noteAuthorAvatar", entry.notesRef.getAuthorIdent()));\r
                                item.add(WicketUtils.createTimestampLabel("authorDate", entry.notesRef\r
                                                .getAuthorIdent().getWhen(), getTimeZone(), getTimeUtils()));\r
-                               item.add(new Label("noteContent", GitBlit.self().processPlainCommitMessage(repositoryName,\r
+                               item.add(new Label("noteContent", messageProcessor().processPlainCommitMessage(repositoryName,\r
                                                entry.content)).setEscapeModelStrings(false));\r
                        }\r
                };\r
index 46adcffeaeb5933e8e1485376e7cbd72545b137f..959a3d3122bb178098a6e8fdb48d19a78f32f424 100644 (file)
@@ -34,7 +34,6 @@ import org.apache.wicket.markup.html.basic.Label;
 import org.apache.wicket.markup.html.panel.Fragment;\r
 import org.eclipse.jgit.lib.Repository;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.DailyLogEntry;\r
 import com.gitblit.models.Metric;\r
@@ -83,7 +82,7 @@ public abstract class DashboardPage extends RootPage {
                                continue;\r
                        }\r
                        if (model.hasCommits && model.lastChange.after(minimumDate)) {\r
-                               Repository repository = GitBlit.self().getRepository(model.name);\r
+                               Repository repository = app().repositories().getRepository(model.name);\r
                                List<DailyLogEntry> entries = RefLogUtils.getDailyLogByRef(model.name, repository, minimumDate, timezone);\r
                                digests.addAll(entries);\r
                                repository.close();\r
@@ -123,7 +122,7 @@ public abstract class DashboardPage extends RootPage {
                if (!ArrayUtils.isEmpty(digests)) {\r
                        // aggregate author exclusions\r
                        Set<String> authorExclusions = new TreeSet<String>();\r
-                       for (String author : GitBlit.getStrings(Keys.web.metricAuthorExclusions)) {\r
+                       for (String author : app().settings().getStrings(Keys.web.metricAuthorExclusions)) {\r
                                authorExclusions.add(author.toLowerCase());\r
                        }\r
                        for (RepositoryModel model : repositories) {\r
@@ -217,7 +216,7 @@ public abstract class DashboardPage extends RootPage {
                frag.add(new Label("feedheader", MessageFormat.format(headerPattern,\r
                                daysBack, totalCommits, authorMetrics.size())));\r
 \r
-               if (GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {\r
+               if (app().settings().getBoolean(Keys.web.generateActivityGraph, true)) {\r
                        // build google charts\r
                        GoogleCharts charts = new GoogleCharts();\r
 \r
index ab0c4623230117ac9e9803cc43669dda84a3b084..03d233728bae5aed0911999bea535a91e3b9b9d9 100644 (file)
@@ -24,7 +24,6 @@ import org.apache.wicket.markup.html.panel.Fragment;
 import org.eclipse.jgit.lib.Repository;\r
 import org.eclipse.jgit.revwalk.RevCommit;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.StringUtils;\r
 import com.gitblit.wicket.CacheControl;\r
@@ -41,11 +40,11 @@ public class DocPage extends RepositoryPage {
                super(params);\r
 \r
                final String path = WicketUtils.getPath(params).replace("%2f", "/").replace("%2F", "/");\r
-               MarkupProcessor processor = new MarkupProcessor(GitBlit.getSettings());\r
+               MarkupProcessor processor = new MarkupProcessor(app().settings());\r
 \r
                Repository r = getRepository();\r
                RevCommit commit = JGitUtils.getCommit(r, objectId);\r
-               String [] encodings = GitBlit.getEncodings();\r
+               String [] encodings = getEncodings();\r
 \r
                // Read raw markup content and transform it to html\r
                String documentPath = path;\r
index 174311c46746d67ab251e761b7d3ba0d22bb485e..3f9ccdb5a95272e59aa418023e19f9f27c6e0da2 100644 (file)
@@ -30,7 +30,6 @@ import org.apache.wicket.markup.repeater.data.ListDataProvider;
 import org.eclipse.jgit.lib.Repository;\r
 import org.eclipse.jgit.revwalk.RevCommit;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.models.PathModel;\r
 import com.gitblit.utils.ByteFormat;\r
 import com.gitblit.utils.JGitUtils;\r
@@ -49,7 +48,7 @@ public class DocsPage extends RepositoryPage {
        public DocsPage(PageParameters params) {\r
                super(params);\r
 \r
-               MarkupProcessor processor = new MarkupProcessor(GitBlit.getSettings());\r
+               MarkupProcessor processor = new MarkupProcessor(app().settings());\r
 \r
                Repository r = getRepository();\r
                RevCommit head = JGitUtils.getCommit(r, null);\r
index 1b3cbd6cab8e92963efd3053337b15f1197a923f..76b34f3abba5f47e091e4c6e1a852eece3392880 100644 (file)
@@ -55,7 +55,6 @@ import com.gitblit.Constants.AuthorizationControl;
 import com.gitblit.Constants.CommitMessageRenderer;\r
 import com.gitblit.Constants.FederationStrategy;\r
 import com.gitblit.Constants.RegistrantType;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.GitBlitException;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.RegistrantAccessPermission;\r
@@ -86,9 +85,9 @@ public class EditRepositoryPage extends RootSubPage {
                super();\r
                isCreate = true;\r
                RepositoryModel model = new RepositoryModel();\r
-               String restriction = GitBlit.getString(Keys.git.defaultAccessRestriction, "PUSH");\r
+               String restriction = app().settings().getString(Keys.git.defaultAccessRestriction, "PUSH");\r
                model.accessRestriction = AccessRestrictionType.fromName(restriction);\r
-               String authorization = GitBlit.getString(Keys.git.defaultAuthorizationControl, null);\r
+               String authorization = app().settings().getString(Keys.git.defaultAuthorizationControl, null);\r
                model.authorizationControl = AuthorizationControl.fromName(authorization);\r
 \r
                GitBlitWebSession session = GitBlitWebSession.get();\r
@@ -113,7 +112,7 @@ public class EditRepositoryPage extends RootSubPage {
                super(params);\r
                isCreate = false;\r
                String name = WicketUtils.getRepositoryName(params);\r
-               RepositoryModel model = GitBlit.self().getRepositoryModel(name);\r
+               RepositoryModel model = app().repositories().getRepositoryModel(name);\r
                setupPage(model);\r
                setStatelessHint(false);\r
                setOutputMarkupId(true);\r
@@ -154,8 +153,8 @@ public class EditRepositoryPage extends RootSubPage {
                        }\r
                } else {\r
                        super.setupPage(getString("gb.edit"), repositoryModel.name);\r
-                       repositoryUsers.addAll(GitBlit.self().getUserAccessPermissions(repositoryModel));\r
-                       repositoryTeams.addAll(GitBlit.self().getTeamAccessPermissions(repositoryModel));\r
+                       repositoryUsers.addAll(app().repositories().getUserAccessPermissions(repositoryModel));\r
+                       repositoryTeams.addAll(app().repositories().getTeamAccessPermissions(repositoryModel));\r
                        Collections.sort(repositoryUsers);\r
                        Collections.sort(repositoryTeams);\r
 \r
@@ -168,13 +167,13 @@ public class EditRepositoryPage extends RootSubPage {
                final String oldName = repositoryModel.name;\r
 \r
                final RegistrantPermissionsPanel usersPalette = new RegistrantPermissionsPanel("users",\r
-                               RegistrantType.USER, GitBlit.self().getAllUsernames(), repositoryUsers, getAccessPermissions());\r
+                               RegistrantType.USER, app().users().getAllUsernames(), repositoryUsers, getAccessPermissions());\r
                final RegistrantPermissionsPanel teamsPalette = new RegistrantPermissionsPanel("teams",\r
-                               RegistrantType.TEAM, GitBlit.self().getAllTeamnames(), repositoryTeams, getAccessPermissions());\r
+                               RegistrantType.TEAM, app().users().getAllTeamnames(), repositoryTeams, getAccessPermissions());\r
 \r
                // owners palette\r
                List<String> owners = new ArrayList<String>(repositoryModel.owners);\r
-               List<String> persons = GitBlit.self().getAllUsernames();\r
+               List<String> persons = app().users().getAllUsernames();\r
                final Palette<String> ownersPalette = new Palette<String>("owners", new ListModel<String>(owners), new CollectionModel<String>(\r
                      persons), new StringChoiceRenderer(), 12, true);\r
 \r
@@ -182,14 +181,14 @@ public class EditRepositoryPage extends RootSubPage {
                List<String> allLocalBranches = new ArrayList<String>();\r
                allLocalBranches.add(Constants.DEFAULT_BRANCH);\r
                allLocalBranches.addAll(repositoryModel.getLocalBranches());\r
-               boolean luceneEnabled = GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true);\r
+               boolean luceneEnabled = app().settings().getBoolean(Keys.web.allowLuceneIndexing, true);\r
                final Palette<String> indexedBranchesPalette = new Palette<String>("indexedBranches", new ListModel<String>(\r
                                indexedBranches), new CollectionModel<String>(allLocalBranches),\r
                                new StringChoiceRenderer(), 8, false);\r
                indexedBranchesPalette.setEnabled(luceneEnabled);\r
 \r
                // federation sets palette\r
-               List<String> sets = GitBlit.getStrings(Keys.federation.sets);\r
+               List<String> sets = app().settings().getStrings(Keys.federation.sets);\r
                final Palette<String> federationSetsPalette = new Palette<String>("federationSets",\r
                                new ListModel<String>(federationSets), new CollectionModel<String>(sets),\r
                                new StringChoiceRenderer(), 8, false);\r
@@ -199,8 +198,8 @@ public class EditRepositoryPage extends RootSubPage {
                        preReceiveScripts.addAll(repositoryModel.preReceiveScripts);\r
                }\r
                final Palette<String> preReceivePalette = new Palette<String>("preReceiveScripts",\r
-                               new ListModel<String>(preReceiveScripts), new CollectionModel<String>(GitBlit\r
-                                               .self().getPreReceiveScriptsUnused(repositoryModel)),\r
+                               new ListModel<String>(preReceiveScripts), new CollectionModel<String>(app().repositories()\r
+                                               .getPreReceiveScriptsUnused(repositoryModel)),\r
                                new StringChoiceRenderer(), 12, true);\r
 \r
                // post-receive palette\r
@@ -208,12 +207,12 @@ public class EditRepositoryPage extends RootSubPage {
                        postReceiveScripts.addAll(repositoryModel.postReceiveScripts);\r
                }\r
                final Palette<String> postReceivePalette = new Palette<String>("postReceiveScripts",\r
-                               new ListModel<String>(postReceiveScripts), new CollectionModel<String>(GitBlit\r
-                                               .self().getPostReceiveScriptsUnused(repositoryModel)),\r
+                               new ListModel<String>(postReceiveScripts), new CollectionModel<String>(app().repositories()\r
+                                               .getPostReceiveScriptsUnused(repositoryModel)),\r
                                new StringChoiceRenderer(), 12, true);\r
 \r
                // custom fields\r
-               final Map<String, String> customFieldsMap = GitBlit.getMap(Keys.groovy.customFields);\r
+               final Map<String, String> customFieldsMap = app().settings().getMap(Keys.groovy.customFields);\r
                List<String> customKeys = new ArrayList<String>(customFieldsMap.keySet());\r
                final ListView<String> customFieldsListView = new ListView<String>("customFieldsListView", customKeys) {\r
 \r
@@ -393,12 +392,12 @@ public class EditRepositoryPage extends RootSubPage {
                                        }\r
 \r
                                        // save the repository\r
-                                       GitBlit.self().updateRepositoryModel(oldName, repositoryModel, isCreate);\r
+                                       app().repositories().updateRepositoryModel(oldName, repositoryModel, isCreate);\r
 \r
                                        // repository access permissions\r
                                        if (repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE)) {\r
-                                               GitBlit.self().setUserAccessPermissions(repositoryModel, repositoryUsers);\r
-                                               GitBlit.self().setTeamAccessPermissions(repositoryModel, repositoryTeams);\r
+                                               app().repositories().setUserAccessPermissions(repositoryModel, repositoryUsers);\r
+                                               app().repositories().setTeamAccessPermissions(repositoryModel, repositoryTeams);\r
                                        }\r
                                } catch (GitBlitException e) {\r
                                        error(e.getMessage());\r
@@ -416,9 +415,9 @@ public class EditRepositoryPage extends RootSubPage {
                form.add(new TextField<String>("name").setEnabled(allowEditName));\r
                form.add(new TextField<String>("description"));\r
                form.add(ownersPalette);\r
-               form.add(new CheckBox("allowForks").setEnabled(GitBlit.getBoolean(Keys.web.allowForking, true)));\r
+               form.add(new CheckBox("allowForks").setEnabled(app().settings().getBoolean(Keys.web.allowForking, true)));\r
                DropDownChoice<AccessRestrictionType> accessRestriction = new DropDownChoice<AccessRestrictionType>("accessRestriction",\r
-                               AccessRestrictionType.choices(GitBlit.getBoolean(Keys.git.allowAnonymousPushes, false)), new AccessRestrictionRenderer());\r
+                               AccessRestrictionType.choices(app().settings().getBoolean(Keys.git.allowAnonymousPushes, false)), new AccessRestrictionRenderer());\r
                form.add(accessRestriction);\r
                form.add(new CheckBox("isFrozen"));\r
                // TODO enable origin definition\r
@@ -431,7 +430,7 @@ public class EditRepositoryPage extends RootSubPage {
                }\r
                form.add(new DropDownChoice<String>("HEAD", availableRefs).setEnabled(availableRefs.size() > 0));\r
 \r
-               boolean gcEnabled = GitBlit.getBoolean(Keys.git.enableGarbageCollection, false);\r
+               boolean gcEnabled = app().settings().getBoolean(Keys.git.enableGarbageCollection, false);\r
                List<Integer> gcPeriods = Arrays.asList(1, 2, 3, 4, 5, 7, 10, 14 );\r
                form.add(new DropDownChoice<Integer>("gcPeriod", gcPeriods, new GCPeriodRenderer()).setEnabled(gcEnabled));\r
                form.add(new TextField<String>("gcThreshold").setEnabled(gcEnabled));\r
@@ -474,15 +473,15 @@ public class EditRepositoryPage extends RootSubPage {
                form.add(teamsPalette);\r
                form.add(federationSetsPalette);\r
                form.add(preReceivePalette);\r
-               form.add(new BulletListPanel("inheritedPreReceive", getString("gb.inherited"), GitBlit.self()\r
+               form.add(new BulletListPanel("inheritedPreReceive", getString("gb.inherited"), app().repositories()\r
                                .getPreReceiveScriptsInherited(repositoryModel)));\r
                form.add(postReceivePalette);\r
-               form.add(new BulletListPanel("inheritedPostReceive", getString("gb.inherited"), GitBlit.self()\r
+               form.add(new BulletListPanel("inheritedPostReceive", getString("gb.inherited"), app().repositories()\r
                                .getPostReceiveScriptsInherited(repositoryModel)));\r
 \r
                WebMarkupContainer customFieldsSection = new WebMarkupContainer("customFieldsSection");\r
                customFieldsSection.add(customFieldsListView);\r
-               form.add(customFieldsSection.setVisible(!GitBlit.getString(Keys.groovy.customFields, "").isEmpty()));\r
+               form.add(customFieldsSection.setVisible(!app().settings().getString(Keys.groovy.customFields, "").isEmpty()));\r
 \r
                // initial enable/disable of permission controls\r
                if (repositoryModel.accessRestriction.equals(AccessRestrictionType.NONE)) {\r
@@ -579,8 +578,8 @@ public class EditRepositoryPage extends RootSubPage {
         * Repository Owners should be able to edit their repository.\r
         */\r
        private void checkPermissions(RepositoryModel model) {\r
-               boolean authenticateAdmin = GitBlit.getBoolean(Keys.web.authenticateAdminPages, true);\r
-               boolean allowAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, true);\r
+               boolean authenticateAdmin = app().settings().getBoolean(Keys.web.authenticateAdminPages, true);\r
+               boolean allowAdmin = app().settings().getBoolean(Keys.web.allowAdministration, true);\r
 \r
                GitBlitWebSession session = GitBlitWebSession.get();\r
                UserModel user = session.getUser();\r
index 617aa86b3d966751f5b1d64a5b9f825501a2034a..32905c95b1bc462d115aa11c584257f2b2d8f491 100644 (file)
@@ -37,7 +37,6 @@ import org.apache.wicket.model.util.CollectionModel;
 import org.apache.wicket.model.util.ListModel;\r
 \r
 import com.gitblit.Constants.RegistrantType;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.GitBlitException;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.RegistrantAccessPermission;\r
@@ -70,7 +69,7 @@ public class EditTeamPage extends RootSubPage {
                super(params);\r
                isCreate = false;\r
                String name = WicketUtils.getTeamname(params);\r
-               TeamModel model = GitBlit.self().getTeamModel(name);\r
+               TeamModel model = app().users().getTeamModel(name);\r
                setupPage(model);\r
                setStatelessHint(false);\r
                setOutputMarkupId(true);\r
@@ -107,7 +106,7 @@ public class EditTeamPage extends RootSubPage {
 \r
                // users palette\r
                final Palette<String> users = new Palette<String>("users", new ListModel<String>(\r
-                               new ArrayList<String>(teamUsers)), new CollectionModel<String>(GitBlit.self()\r
+                               new ArrayList<String>(teamUsers)), new CollectionModel<String>(app().users()\r
                                .getAllUsernames()), new StringChoiceRenderer(), 10, false);\r
 \r
                // pre-receive palette\r
@@ -115,8 +114,8 @@ public class EditTeamPage extends RootSubPage {
                        preReceiveScripts.addAll(teamModel.preReceiveScripts);\r
                }\r
                final Palette<String> preReceivePalette = new Palette<String>("preReceiveScripts",\r
-                               new ListModel<String>(preReceiveScripts), new CollectionModel<String>(GitBlit\r
-                                               .self().getPreReceiveScriptsUnused(null)), new StringChoiceRenderer(),\r
+                               new ListModel<String>(preReceiveScripts), new CollectionModel<String>(app().repositories()\r
+                                               .getPreReceiveScriptsUnused(null)), new StringChoiceRenderer(),\r
                                                12, true);\r
 \r
                // post-receive palette\r
@@ -124,8 +123,8 @@ public class EditTeamPage extends RootSubPage {
                        postReceiveScripts.addAll(teamModel.postReceiveScripts);\r
                }\r
                final Palette<String> postReceivePalette = new Palette<String>("postReceiveScripts",\r
-                               new ListModel<String>(postReceiveScripts), new CollectionModel<String>(GitBlit\r
-                                               .self().getPostReceiveScriptsUnused(null)), new StringChoiceRenderer(),\r
+                               new ListModel<String>(postReceiveScripts), new CollectionModel<String>(app().repositories()\r
+                                               .getPostReceiveScriptsUnused(null)), new StringChoiceRenderer(),\r
                                                                12, true);\r
 \r
                Form<TeamModel> form = new Form<TeamModel>("editForm", model) {\r
@@ -145,7 +144,7 @@ public class EditTeamPage extends RootSubPage {
                                        return;\r
                                }\r
                                if (isCreate) {\r
-                                       TeamModel model = GitBlit.self().getTeamModel(teamname);\r
+                                       TeamModel model = app().users().getTeamModel(teamname);\r
                                        if (model != null) {\r
                                                error(MessageFormat.format(getString("gb.teamNameUnavailable"), teamname));\r
                                                return;\r
@@ -197,7 +196,7 @@ public class EditTeamPage extends RootSubPage {
                                teamModel.postReceiveScripts.addAll(postReceiveScripts);\r
 \r
                                try {\r
-                                       GitBlit.self().updateTeamModel(oldName, teamModel, isCreate);\r
+                                       app().users().updateTeamModel(oldName, teamModel, isCreate);\r
                                } catch (GitBlitException e) {\r
                                        error(e.getMessage());\r
                                        return;\r
@@ -217,12 +216,12 @@ public class EditTeamPage extends RootSubPage {
                form.add(new SimpleAttributeModifier("autocomplete", "off"));\r
 \r
                // not all user services support manipulating team memberships\r
-               boolean editMemberships = GitBlit.self().supportsTeamMembershipChanges(null);\r
+               boolean editMemberships = app().users().supportsTeamMembershipChanges(null);\r
 \r
                // field names reflective match TeamModel fields\r
                form.add(new TextField<String>("name"));\r
                form.add(new CheckBox("canAdmin"));\r
-               form.add(new CheckBox("canFork").setEnabled(GitBlit.getBoolean(Keys.web.allowForking, true)));\r
+               form.add(new CheckBox("canFork").setEnabled(app().settings().getBoolean(Keys.web.allowForking, true)));\r
                form.add(new CheckBox("canCreate"));\r
                form.add(users.setEnabled(editMemberships));\r
                mailingLists = new Model<String>(teamModel.mailingLists == null ? ""\r
@@ -232,10 +231,10 @@ public class EditTeamPage extends RootSubPage {
                form.add(new RegistrantPermissionsPanel("repositories", RegistrantType.REPOSITORY,\r
                                repos, permissions, getAccessPermissions()));\r
                form.add(preReceivePalette);\r
-               form.add(new BulletListPanel("inheritedPreReceive", "inherited", GitBlit.self()\r
+               form.add(new BulletListPanel("inheritedPreReceive", "inherited", app().repositories()\r
                                .getPreReceiveScriptsInherited(null)));\r
                form.add(postReceivePalette);\r
-               form.add(new BulletListPanel("inheritedPostReceive", "inherited", GitBlit.self()\r
+               form.add(new BulletListPanel("inheritedPostReceive", "inherited", app().repositories()\r
                                .getPostReceiveScriptsInherited(null)));\r
 \r
                form.add(new Button("save"));\r
index 6838c1964eba312c67af280a1f4eaeeefc6622cb..d0e52f469a294ea51adb4b5ff1fc5e91268dde45 100644 (file)
@@ -35,7 +35,6 @@ import org.apache.wicket.model.util.CollectionModel;
 import org.apache.wicket.model.util.ListModel;\r
 \r
 import com.gitblit.Constants.RegistrantType;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.GitBlitException;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.RegistrantAccessPermission;\r
@@ -55,9 +54,9 @@ public class EditUserPage extends RootSubPage {
        public EditUserPage() {\r
                // create constructor\r
                super();\r
-               if (!GitBlit.self().supportsAddUser()) {\r
+               if (!app().users().supportsAddUser()) {\r
                        error(MessageFormat.format(getString("gb.userServiceDoesNotPermitAddUser"),\r
-                                       GitBlit.getString(Keys.realm.userService, "${baseFolder}/users.conf")), true);\r
+                                       app().settings().getString(Keys.realm.userService, "${baseFolder}/users.conf")), true);\r
                }\r
                isCreate = true;\r
                setupPage(new UserModel(""));\r
@@ -70,7 +69,7 @@ public class EditUserPage extends RootSubPage {
                super(params);\r
                isCreate = false;\r
                String name = WicketUtils.getUsername(params);\r
-               UserModel model = GitBlit.self().getUserModel(name);\r
+               UserModel model = app().users().getUserModel(name);\r
                setupPage(model);\r
                setStatelessHint(false);\r
                setOutputMarkupId(true);\r
@@ -107,10 +106,10 @@ public class EditUserPage extends RootSubPage {
                Collections.sort(userTeams);\r
 \r
                final String oldName = userModel.username;\r
-               final List<RegistrantAccessPermission> permissions = GitBlit.self().getUserAccessPermissions(userModel);\r
+               final List<RegistrantAccessPermission> permissions = app().repositories().getUserAccessPermissions(userModel);\r
 \r
                final Palette<String> teams = new Palette<String>("teams", new ListModel<String>(\r
-                               new ArrayList<String>(userTeams)), new CollectionModel<String>(GitBlit.self()\r
+                               new ArrayList<String>(userTeams)), new CollectionModel<String>(app().users()\r
                                .getAllTeamnames()), new StringChoiceRenderer(), 10, false);\r
                Form<UserModel> form = new Form<UserModel>("editForm", model) {\r
 \r
@@ -131,7 +130,7 @@ public class EditUserPage extends RootSubPage {
                                userModel.username = userModel.username.toLowerCase();\r
                                String username = userModel.username;\r
                                if (isCreate) {\r
-                                       UserModel model = GitBlit.self().getUserModel(username);\r
+                                       UserModel model = app().users().getUserModel(username);\r
                                        if (model != null) {\r
                                                error(MessageFormat.format(getString("gb.usernameUnavailable"), username));\r
                                                return;\r
@@ -139,7 +138,7 @@ public class EditUserPage extends RootSubPage {
                                }\r
                                boolean rename = !StringUtils.isEmpty(oldName)\r
                                                && !oldName.equalsIgnoreCase(username);\r
-                               if (GitBlit.self().supportsCredentialChanges(userModel)) {\r
+                               if (app().users().supportsCredentialChanges(userModel)) {\r
                                        if (!userModel.password.equals(confirmPassword.getObject())) {\r
                                                error(getString("gb.passwordsDoNotMatch"));\r
                                                return;\r
@@ -149,7 +148,7 @@ public class EditUserPage extends RootSubPage {
                                                        && !password.toUpperCase().startsWith(StringUtils.COMBINED_MD5_TYPE)) {\r
                                                // This is a plain text password.\r
                                                // Check length.\r
-                                               int minLength = GitBlit.getInteger(Keys.realm.minPasswordLength, 5);\r
+                                               int minLength = app().settings().getInteger(Keys.realm.minPasswordLength, 5);\r
                                                if (minLength < 4) {\r
                                                        minLength = 4;\r
                                                }\r
@@ -160,7 +159,7 @@ public class EditUserPage extends RootSubPage {
                                                }\r
 \r
                                                // Optionally store the password MD5 digest.\r
-                                               String type = GitBlit.getString(Keys.realm.passwordStorage, "md5");\r
+                                               String type = app().settings().getString(Keys.realm.passwordStorage, "md5");\r
                                                if (type.equalsIgnoreCase("md5")) {\r
                                                        // store MD5 digest of password\r
                                                        userModel.password = StringUtils.MD5_TYPE\r
@@ -185,7 +184,7 @@ public class EditUserPage extends RootSubPage {
                                Iterator<String> selectedTeams = teams.getSelectedChoices();\r
                                userModel.teams.clear();\r
                                while (selectedTeams.hasNext()) {\r
-                                       TeamModel team = GitBlit.self().getTeamModel(selectedTeams.next());\r
+                                       TeamModel team = app().users().getTeamModel(selectedTeams.next());\r
                                        if (team == null) {\r
                                                continue;\r
                                        }\r
@@ -193,7 +192,7 @@ public class EditUserPage extends RootSubPage {
                                }\r
 \r
                                try {\r
-                                       GitBlit.self().updateUserModel(oldName, userModel, isCreate);\r
+                                       app().users().updateUserModel(oldName, userModel, isCreate);\r
                                } catch (GitBlitException e) {\r
                                        error(e.getMessage());\r
                                        return;\r
@@ -215,16 +214,16 @@ public class EditUserPage extends RootSubPage {
                form.add(new SimpleAttributeModifier("autocomplete", "off"));\r
 \r
                // not all user services support manipulating username and password\r
-               boolean editCredentials = GitBlit.self().supportsCredentialChanges(userModel);\r
+               boolean editCredentials = app().users().supportsCredentialChanges(userModel);\r
 \r
                // not all user services support manipulating display name\r
-               boolean editDisplayName = GitBlit.self().supportsDisplayNameChanges(userModel);\r
+               boolean editDisplayName = app().users().supportsDisplayNameChanges(userModel);\r
 \r
                // not all user services support manipulating email address\r
-               boolean editEmailAddress = GitBlit.self().supportsEmailAddressChanges(userModel);\r
+               boolean editEmailAddress = app().users().supportsEmailAddressChanges(userModel);\r
 \r
                // not all user services support manipulating team memberships\r
-               boolean editTeams = GitBlit.self().supportsTeamMembershipChanges(userModel);\r
+               boolean editTeams = app().users().supportsTeamMembershipChanges(userModel);\r
 \r
                // field names reflective match UserModel fields\r
                form.add(new TextField<String>("username").setEnabled(editCredentials));\r
@@ -238,7 +237,7 @@ public class EditUserPage extends RootSubPage {
                form.add(new TextField<String>("displayName").setEnabled(editDisplayName));\r
                form.add(new TextField<String>("emailAddress").setEnabled(editEmailAddress));\r
                form.add(new CheckBox("canAdmin"));\r
-               form.add(new CheckBox("canFork").setEnabled(GitBlit.getBoolean(Keys.web.allowForking, true)));\r
+               form.add(new CheckBox("canFork").setEnabled(app().settings().getBoolean(Keys.web.allowForking, true)));\r
                form.add(new CheckBox("canCreate"));\r
                form.add(new CheckBox("excludeFromFederation"));\r
                form.add(new RegistrantPermissionsPanel("repositories", RegistrantType.REPOSITORY, repos, permissions, getAccessPermissions()));\r
index 4e05fad6a07c6c6a54f3f86aef683b591352e1fa..9e4d355c9fd254f52010462ecbdc7dcd409bf199 100644 (file)
@@ -24,7 +24,6 @@ import org.apache.wicket.PageParameters;
 import org.apache.wicket.markup.html.basic.Label;\r
 import org.apache.wicket.protocol.http.WebRequest;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.RepositoryUrl;\r
 import com.gitblit.models.UserModel;\r
@@ -41,7 +40,7 @@ public class EmptyRepositoryPage extends RootPage {
                setVersioned(false);\r
 \r
                String repositoryName = WicketUtils.getRepositoryName(params);\r
-               RepositoryModel repository = GitBlit.self().getRepositoryModel(repositoryName);\r
+               RepositoryModel repository = app().repositories().getRepositoryModel(repositoryName);\r
                if (repository == null) {\r
                        error(getString("gb.canNotLoadRepository") + " " + repositoryName, true);\r
                }\r
@@ -59,7 +58,7 @@ public class EmptyRepositoryPage extends RootPage {
                }\r
 \r
                HttpServletRequest req = ((WebRequest) getRequest()).getHttpServletRequest();\r
-               List<RepositoryUrl> repositoryUrls = GitBlit.self().getRepositoryUrls(req, user, repository);\r
+               List<RepositoryUrl> repositoryUrls = app().repositories().getRepositoryUrls(req, user, repository);\r
                RepositoryUrl primaryUrl = repositoryUrls.size() == 0 ? null : repositoryUrls.get(0);\r
                String url = primaryUrl != null ? primaryUrl.url : "";\r
 \r
index 1f98c1727d2950808686c387b7e99814def00331..a834293855f7b5a7325040b4f44e2e40938a2779 100644 (file)
@@ -15,7 +15,6 @@
  */\r
 package com.gitblit.wicket.pages;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.wicket.panels.FederationProposalsPanel;\r
 import com.gitblit.wicket.panels.FederationRegistrationsPanel;\r
@@ -27,7 +26,7 @@ public class FederationPage extends RootPage {
                super();\r
                setupPage("", "");\r
 \r
-               boolean showFederation = showAdmin && GitBlit.canFederate();\r
+               boolean showFederation = showAdmin && app().federation().canFederate();\r
                add(new FederationTokensPanel("federationTokensPanel", showFederation)\r
                                .setVisible(showFederation));\r
                FederationProposalsPanel proposalsPanel = new FederationProposalsPanel(\r
@@ -38,7 +37,7 @@ public class FederationPage extends RootPage {
                        proposalsPanel.setVisible(false);\r
                }\r
 \r
-               boolean showRegistrations = GitBlit.getBoolean(Keys.web.showFederationRegistrations, false);\r
+               boolean showRegistrations = app().settings().getBoolean(Keys.web.showFederationRegistrations, false);\r
                FederationRegistrationsPanel registrationsPanel = new FederationRegistrationsPanel(\r
                                "federationRegistrationsPanel");\r
                if (showAdmin || showRegistrations) {\r
index 42f46943936b77c204b3c59f31c66d6a3b18e3b0..c26c9757af1e2666cad2b683e47213f57638af45 100644 (file)
@@ -24,7 +24,6 @@ import org.apache.wicket.markup.repeater.Item;
 import org.apache.wicket.markup.repeater.data.DataView;\r
 import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.models.FederationModel;\r
 import com.gitblit.models.FederationModel.RepositoryStatus;\r
 import com.gitblit.wicket.WicketUtils;\r
@@ -39,7 +38,7 @@ public class FederationRegistrationPage extends RootSubPage {
                String url = WicketUtils.getUrlParameter(params);\r
                String name = WicketUtils.getNameParameter(params);\r
 \r
-               FederationModel registration = GitBlit.self().getFederationRegistration(url, name);\r
+               FederationModel registration = app().federation().getFederationRegistration(url, name);\r
                if (registration == null) {\r
                        error(getString("gb.couldNotFindFederationRegistration"), true);\r
                }\r
index fe316fffe225840c36be3fb0b5b64585b89646d8..12020128f107fbca17d24a96eebeba2e46475cf7 100644 (file)
@@ -21,9 +21,9 @@ import org.apache.wicket.PageParameters;
 import org.apache.wicket.markup.html.basic.Label;\r
 import org.slf4j.LoggerFactory;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.UserModel;\r
+import com.gitblit.wicket.GitBlitWebApp;\r
 import com.gitblit.wicket.GitBlitWebSession;\r
 import com.gitblit.wicket.GitblitRedirectException;\r
 import com.gitblit.wicket.WicketUtils;\r
@@ -49,7 +49,7 @@ public class ForkPage extends RepositoryPage {
                        throw new GitblitRedirectException(SummaryPage.class, WicketUtils.newRepositoryParameter(repository.name));\r
                }\r
 \r
-               String fork = GitBlit.self().getFork(user.username, repository.name);\r
+               String fork = app().repositories().getFork(user.username, repository.name);\r
                if (fork != null) {\r
                        // redirect to user's fork\r
                        throw new GitblitRedirectException(SummaryPage.class, WicketUtils.newRepositoryParameter(fork));\r
@@ -62,7 +62,7 @@ public class ForkPage extends RepositoryPage {
                        session.isForking(true);\r
 \r
                        // fork it\r
-                       ForkThread forker = new ForkThread(repository, session);\r
+                       ForkThread forker = new ForkThread(app(), repository, session);\r
                        forker.start();\r
                }\r
        }\r
@@ -84,10 +84,12 @@ public class ForkPage extends RepositoryPage {
         */\r
        private static class ForkThread extends Thread {\r
 \r
+               private final GitBlitWebApp app;\r
                private final RepositoryModel repository;\r
                private final GitBlitWebSession session;\r
 \r
-               public ForkThread(RepositoryModel repository, GitBlitWebSession session) {\r
+               public ForkThread(GitBlitWebApp app, RepositoryModel repository, GitBlitWebSession session) {\r
+                       this.app = app;\r
                        this.repository = repository;\r
                        this.session = session;\r
                }\r
@@ -96,7 +98,7 @@ public class ForkPage extends RepositoryPage {
                public void run() {\r
                        UserModel user = session.getUser();\r
                        try {\r
-                               GitBlit.self().fork(repository, user);\r
+                               app.gitblit().fork(repository, user);\r
                        } catch (Exception e) {\r
                                LoggerFactory.getLogger(ForkPage.class).error(MessageFormat.format("Failed to fork {0} for {1}", repository.name, user.username), e);\r
                        } finally {\r
index 5b5fcc0af29786eee428933d01fbddaa83520d27..9fd7f4db7f36538d53a51fc48503f1559f50353d 100644 (file)
@@ -27,7 +27,6 @@ import org.apache.wicket.markup.repeater.data.DataView;
 import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
 import org.eclipse.jgit.lib.PersonIdent;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.ForkModel;\r
 import com.gitblit.models.RepositoryModel;\r
@@ -45,7 +44,7 @@ public class ForksPage extends RepositoryPage {
 \r
                final RepositoryModel pageRepository = getRepositoryModel();\r
 \r
-               ForkModel root = GitBlit.self().getForkNetwork(pageRepository.name);\r
+               ForkModel root = app().repositories().getForkNetwork(pageRepository.name);\r
                List<FlatFork> network = flatten(root);\r
 \r
                ListDataProvider<FlatFork> forksDp = new ListDataProvider<FlatFork>(network);\r
@@ -58,7 +57,7 @@ public class ForksPage extends RepositoryPage {
                                RepositoryModel repository = fork.repository;\r
 \r
                                if (repository.isPersonalRepository()) {\r
-                                       UserModel user = GitBlit.self().getUserModel(repository.projectPath.substring(1));\r
+                                       UserModel user = app().users().getUserModel(repository.projectPath.substring(1));\r
                                        if (user == null) {\r
                                                // user account no longer exists\r
                                                user = new UserModel(repository.projectPath.substring(1));\r
@@ -84,7 +83,7 @@ public class ForksPage extends RepositoryPage {
                                        item.add(swatch);\r
                                        String projectName = repository.projectPath;\r
                                        if (StringUtils.isEmpty(projectName)) {\r
-                                               projectName = GitBlit.getString(Keys.web.repositoryRootGroupName, "main");\r
+                                               projectName = app().settings().getString(Keys.web.repositoryRootGroupName, "main");\r
                                        }\r
                                        if (pageRepository.equals(repository)) {\r
                                                // do not link to self\r
index ff3b507fb2f4129c567db2a64be0a0c42176d71f..f7be99aea54931c64c47a0e5945568157482dbb2 100644 (file)
@@ -18,7 +18,6 @@ package com.gitblit.wicket.pages;
 import org.apache.wicket.protocol.http.WebRequest;\r
 import org.apache.wicket.protocol.http.WebResponse;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.models.UserModel;\r
 import com.gitblit.wicket.GitBlitWebSession;\r
 \r
@@ -28,8 +27,8 @@ public class LogoutPage extends BasePage {
                super();\r
                GitBlitWebSession session = GitBlitWebSession.get();\r
                UserModel user = session.getUser();\r
-               GitBlit.self().setCookie((WebResponse) getResponse(), null);\r
-               GitBlit.self().logout(user);\r
+               app().session().setCookie((WebResponse) getResponse(), null);\r
+               app().session().logout(user);\r
                session.invalidate();\r
 \r
                /*\r
index 86a426ca30123111e883c3453eb8e4595518fd66..4d4545a5e6177672355ae5b255c276d081dc5985 100644 (file)
@@ -32,7 +32,6 @@ import org.apache.wicket.model.Model;
 import org.eclipse.jgit.lib.Constants;\r
 \r
 import com.gitblit.Constants.SearchType;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.SearchResult;\r
@@ -65,7 +64,7 @@ public class LuceneSearchPage extends RootPage {
                ArrayList<String> repositories = new ArrayList<String>();\r
                String query = "";\r
                int page = 1;\r
-               int pageSize = GitBlit.getInteger(Keys.web.itemsPerPage, 50);\r
+               int pageSize = app().settings().getInteger(Keys.web.itemsPerPage, 50);\r
 \r
                if (params != null) {\r
                        String repository = WicketUtils.getRepositoryName(params);\r
@@ -100,12 +99,12 @@ public class LuceneSearchPage extends RootPage {
                // display user-accessible selections\r
                UserModel user = GitBlitWebSession.get().getUser();\r
                List<String> availableRepositories = new ArrayList<String>();\r
-               for (RepositoryModel model : GitBlit.self().getRepositoryModels(user)) {\r
+               for (RepositoryModel model : app().repositories().getRepositoryModels(user)) {\r
                        if (model.hasCommits && !ArrayUtils.isEmpty(model.indexedBranches)) {\r
                                availableRepositories.add(model.name);\r
                        }\r
                }\r
-               boolean luceneEnabled = GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true);\r
+               boolean luceneEnabled = app().settings().getBoolean(Keys.web.allowLuceneIndexing, true);\r
                if (luceneEnabled) {\r
                        if (availableRepositories.size() == 0) {\r
                                info(getString("gb.noIndexedRepositoriesWarning"));\r
@@ -158,7 +157,7 @@ public class LuceneSearchPage extends RootPage {
                // execute search\r
                final List<SearchResult> results = new ArrayList<SearchResult>();\r
                if (!ArrayUtils.isEmpty(searchRepositories) && !StringUtils.isEmpty(query)) {\r
-                       results.addAll(GitBlit.self().search(query, page, pageSize, searchRepositories));\r
+                       results.addAll(app().repositories().search(query, page, pageSize, searchRepositories));\r
                }\r
 \r
                // results header\r
index 8e05b4f07d7fe0ac0afcbfe7177a15699d24c2bd..ba85b8224fa379f4aa575d923b7fe575c1e19564 100644 (file)
@@ -35,7 +35,6 @@ import org.apache.wicket.markup.html.basic.Label;
 import org.apache.wicket.markup.html.panel.Fragment;\r
 import org.eclipse.jgit.lib.Constants;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.ProjectModel;\r
 import com.gitblit.models.RepositoryModel;\r
@@ -71,9 +70,9 @@ public class MyDashboardPage extends DashboardPage {
        private void setup(PageParameters params) {\r
                setupPage("", "");\r
                // check to see if we should display a login message\r
-               boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, true);\r
+               boolean authenticateView = app().settings().getBoolean(Keys.web.authenticateViewPages, true);\r
                if (authenticateView && !GitBlitWebSession.get().isLoggedIn()) {\r
-                       String messageSource = GitBlit.getString(Keys.web.loginMessage, "gitblit");\r
+                       String messageSource = app().settings().getString(Keys.web.loginMessage, "gitblit");\r
                        String message = readMarkdown(messageSource, "login.mkd");\r
                        Component repositoriesMessage = new Label("repositoriesMessage", message);\r
                        add(repositoriesMessage.setEscapeModelStrings(false));\r
@@ -83,7 +82,7 @@ public class MyDashboardPage extends DashboardPage {
                }\r
 \r
                // Load the markdown welcome message\r
-               String messageSource = GitBlit.getString(Keys.web.repositoriesMessage, "gitblit");\r
+               String messageSource = app().settings().getString(Keys.web.repositoriesMessage, "gitblit");\r
                String message = readMarkdown(messageSource, "welcome.mkd");\r
                Component repositoriesMessage = new Label("repositoriesMessage", message)\r
                                .setEscapeModelStrings(false).setVisible(message.length() > 0);\r
@@ -96,9 +95,9 @@ public class MyDashboardPage extends DashboardPage {
 \r
                // parameters\r
                int daysBack = params == null ? 0 : WicketUtils.getDaysBack(params);\r
-               int maxDaysBack = GitBlit.getInteger(Keys.web.activityDurationMaximum, 30);\r
+               int maxDaysBack = app().settings().getInteger(Keys.web.activityDurationMaximum, 30);\r
                if (daysBack < 1) {\r
-                       daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);\r
+                       daysBack = app().settings().getInteger(Keys.web.activityDuration, 7);\r
                }\r
                if (maxDaysBack > 0 && daysBack > maxDaysBack) {\r
                        daysBack = maxDaysBack;\r
@@ -168,7 +167,7 @@ public class MyDashboardPage extends DashboardPage {
                add(repositoryTabs);\r
 \r
                // projects list\r
-               List<ProjectModel> projects = GitBlit.self().getProjectModels(getRepositoryModels(), false);\r
+               List<ProjectModel> projects = app().projects().getProjectModels(getRepositoryModels(), false);\r
                repositoryTabs.add(new FilterableProjectList("projects", projects));\r
 \r
                // active repository list\r
@@ -208,7 +207,7 @@ public class MyDashboardPage extends DashboardPage {
                } else {\r
                        // Read user-supplied message\r
                        if (!StringUtils.isEmpty(messageSource)) {\r
-                               File file = GitBlit.getFileOrFolder(messageSource);\r
+                               File file = app().runtime().getFileOrFolder(messageSource);\r
                                if (file.exists()) {\r
                                        try {\r
                                                FileInputStream fis = new FileInputStream(file);\r
index f6362c222b77d1e3be2332f0b6b761e3b7783eef..efb7f4cf54500b5a9232bc1a5c3cf86443d4851f 100644 (file)
@@ -28,7 +28,6 @@ import org.apache.wicket.markup.repeater.data.DataView;
 import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
 import org.eclipse.jgit.lib.Repository;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.Metric;\r
 import com.gitblit.models.RepositoryModel;\r
@@ -53,7 +52,7 @@ public class OverviewPage extends RepositoryPage {
        public OverviewPage(PageParameters params) {\r
                super(params);\r
 \r
-               int numberRefs = GitBlit.getInteger(Keys.web.summaryRefsCount, 5);\r
+               int numberRefs = app().settings().getInteger(Keys.web.summaryRefsCount, 5);\r
 \r
                Repository r = getRepository();\r
                final RepositoryModel model = getRepositoryModel();\r
@@ -64,8 +63,8 @@ public class OverviewPage extends RepositoryPage {
 \r
                List<Metric> metrics = null;\r
                Metric metricsTotal = null;\r
-               if (!model.skipSummaryMetrics && GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {\r
-                       metrics = GitBlit.self().getRepositoryDefaultMetrics(model, r);\r
+               if (!model.skipSummaryMetrics && app().settings().getBoolean(Keys.web.generateActivityGraph, true)) {\r
+                       metrics = app().repositories().getRepositoryDefaultMetrics(model, r);\r
                        metricsTotal = metrics.remove(0);\r
                }\r
 \r
@@ -83,7 +82,7 @@ public class OverviewPage extends RepositoryPage {
                        @Override\r
                        public void populateItem(final Item<String> item) {\r
                                String ownername = item.getModelObject();\r
-                               UserModel ownerModel = GitBlit.self().getUserModel(ownername);\r
+                               UserModel ownerModel = app().users().getUserModel(ownername);\r
                                if (ownerModel != null) {\r
                                        item.add(new LinkPanel("owner", null, ownerModel.getDisplayName(), UserPage.class,\r
                                                        WicketUtils.newUsernameParameter(ownerModel.username)).setRenderBodyOnly(true));\r
@@ -117,7 +116,7 @@ public class OverviewPage extends RepositoryPage {
 \r
                add(new RepositoryUrlPanel("repositoryUrlPanel", false, user, model));\r
 \r
-               int reflogCount = GitBlit.getInteger(Keys.web.overviewReflogCount, 5);\r
+               int reflogCount = app().settings().getInteger(Keys.web.overviewReflogCount, 5);\r
                ReflogPanel reflog = new ReflogPanel("reflogPanel", getRepositoryModel(), r, reflogCount, 0);\r
                add(reflog);\r
                add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs).hideIfEmpty());\r
@@ -134,7 +133,7 @@ public class OverviewPage extends RepositoryPage {
 \r
        private void insertActivityGraph(List<Metric> metrics) {\r
                if ((metrics != null) && (metrics.size() > 0)\r
-                               && GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {\r
+                               && app().settings().getBoolean(Keys.web.generateActivityGraph, true)) {\r
 \r
                        // daily line chart\r
                        GoogleChart chart = new GoogleLineChart("chartDaily", "", "unit",\r
index be959d01b1c4ed0daee47d0a0df57acbe7cbdd12..ece41367ff817173b6a2ac5b20638a1705ebb7c7 100644 (file)
 package com.gitblit.wicket.pages;\r
 \r
 import org.apache.wicket.PageParameters;\r
-import org.apache.wicket.markup.html.WebPage;\r
 import org.apache.wicket.markup.html.basic.Label;\r
 import org.eclipse.jgit.lib.Repository;\r
 import org.eclipse.jgit.revwalk.RevCommit;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.utils.DiffUtils;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.StringUtils;\r
@@ -31,7 +29,7 @@ import com.gitblit.wicket.GitBlitWebSession;
 import com.gitblit.wicket.WicketUtils;\r
 \r
 @CacheControl(LastModified.BOOT)\r
-public class PatchPage extends WebPage {\r
+public class PatchPage extends SessionPage {\r
 \r
        public PatchPage(PageParameters params) {\r
                super(params);\r
@@ -47,7 +45,7 @@ public class PatchPage extends WebPage {
                final String objectId = WicketUtils.getObject(params);\r
                final String blobPath = WicketUtils.getPath(params);\r
 \r
-               Repository r = GitBlit.self().getRepository(repositoryName);\r
+               Repository r = app().repositories().getRepository(repositoryName);\r
                if (r == null) {\r
                        GitBlitWebSession.get().cacheErrorMessage(getString("gb.canNotLoadRepository") + " " + repositoryName);\r
                        redirectToInterceptPage(new RepositoriesPage());\r
index 19588a95240fe11b557f03d28bf02f32c3f752fc..22396bec0f82b95a32144557f64ab7124e79a922 100644 (file)
@@ -25,7 +25,6 @@ import org.apache.wicket.PageParameters;
 import org.apache.wicket.markup.html.basic.Label;\r
 import org.apache.wicket.markup.html.link.ExternalLink;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.SyndicationServlet;\r
 import com.gitblit.models.ProjectModel;\r
@@ -87,7 +86,7 @@ public class ProjectPage extends DashboardPage {
        private void setup(PageParameters params) {\r
                setupPage("", "");\r
                // check to see if we should display a login message\r
-               boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, true);\r
+               boolean authenticateView = app().settings().getBoolean(Keys.web.authenticateViewPages, true);\r
                if (authenticateView && !GitBlitWebSession.get().isLoggedIn()) {\r
                        authenticationError("Please login");\r
                        return;\r
@@ -130,7 +129,7 @@ public class ProjectPage extends DashboardPage {
                }\r
                int daysBack = params == null ? 0 : WicketUtils.getDaysBack(params);\r
                if (daysBack < 1) {\r
-                       daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);\r
+                       daysBack = app().settings().getInteger(Keys.web.activityDuration, 7);\r
                }\r
                // reset the daysback parameter so that we have a complete project\r
                // repository list.  the recent activity will be built up by the\r
@@ -186,7 +185,7 @@ public class ProjectPage extends DashboardPage {
        protected List<ProjectModel> getProjectModels() {\r
                if (projectModels.isEmpty()) {\r
                        List<RepositoryModel> repositories = getRepositoryModels();\r
-                       List<ProjectModel> projects = GitBlit.self().getProjectModels(repositories, false);\r
+                       List<ProjectModel> projects = app().projects().getProjectModels(repositories, false);\r
                        projectModels.addAll(projects);\r
                }\r
                return projectModels;\r
index e5000462136f6f8d6da15330f2e256f36579ccf9..77d4984693126ab1cc028633c42b370ab3290545 100644 (file)
@@ -23,7 +23,6 @@ import org.apache.wicket.markup.repeater.Item;
 import org.apache.wicket.markup.repeater.data.DataView;\r
 import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.ProjectModel;\r
 import com.gitblit.wicket.GitBlitWebSession;\r
@@ -57,13 +56,13 @@ public class ProjectsPage extends RootPage {
 \r
        @Override\r
        protected List<ProjectModel> getProjectModels() {\r
-               return GitBlit.self().getProjectModels(getRepositoryModels(), false);\r
+               return app().projects().getProjectModels(getRepositoryModels(), false);\r
        }\r
 \r
        private void setup(PageParameters params) {\r
                setupPage("", "");\r
                // check to see if we should display a login message\r
-               boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, true);\r
+               boolean authenticateView = app().settings().getBoolean(Keys.web.authenticateViewPages, true);\r
                if (authenticateView && !GitBlitWebSession.get().isLoggedIn()) {\r
                        add(new Label("projectsPanel"));\r
                        return;\r
index 178376491d5d63df01a9aca2e35e72af6a110668..ac4af6d53e7ce80eaa23d8b1b8df47bd6268df5b 100644 (file)
@@ -31,7 +31,6 @@ import org.eclipse.jgit.revwalk.RevCommit;
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.UserModel;\r
@@ -66,11 +65,11 @@ public class RawPage extends SessionPage {
                                final String repositoryName = WicketUtils.getRepositoryName(params);\r
                                final String objectId = WicketUtils.getObject(params);\r
                                final String blobPath = WicketUtils.getPath(params);\r
-                               String[] encodings = GitBlit.getEncodings();\r
+                               String[] encodings = getEncodings();\r
                                GitBlitWebSession session = GitBlitWebSession.get();\r
                                UserModel user = session.getUser();\r
 \r
-                               RepositoryModel model = GitBlit.self().getRepositoryModel(user, repositoryName);\r
+                               RepositoryModel model = app().repositories().getRepositoryModel(user, repositoryName);\r
                                if (model == null) {\r
                                        // user does not have permission\r
                                        error(getString("gb.canNotLoadRepository") + " " + repositoryName);\r
@@ -78,7 +77,7 @@ public class RawPage extends SessionPage {
                                        return;\r
                                }\r
 \r
-                               Repository r = GitBlit.self().getRepository(repositoryName);\r
+                               Repository r = app().repositories().getRepository(repositoryName);\r
                                if (r == null) {\r
                                        error(getString("gb.canNotLoadRepository") + " " + repositoryName);\r
                                        redirectToInterceptPage(new RepositoriesPage());\r
@@ -112,10 +111,10 @@ public class RawPage extends SessionPage {
 \r
                                        // Map the extensions to types\r
                                        Map<String, Integer> map = new HashMap<String, Integer>();\r
-                                       for (String ext : GitBlit.getStrings(Keys.web.imageExtensions)) {\r
+                                       for (String ext : app().settings().getStrings(Keys.web.imageExtensions)) {\r
                                                map.put(ext.toLowerCase(), 2);\r
                                        }\r
-                                       for (String ext : GitBlit.getStrings(Keys.web.binaryExtensions)) {\r
+                                       for (String ext : app().settings().getStrings(Keys.web.binaryExtensions)) {\r
                                                map.put(ext.toLowerCase(), 3);\r
                                        }\r
 \r
index b446279a9598554f9e6ed37164145ff48fc7ac49..70266f8f6b76095ca43ab8ba0d2003f053eb8e7d 100644 (file)
@@ -28,7 +28,6 @@ import org.apache.wicket.PageParameters;
 import org.apache.wicket.markup.html.basic.Label;\r
 import org.eclipse.jgit.lib.Constants;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.utils.MarkdownUtils;\r
@@ -63,9 +62,9 @@ public class RepositoriesPage extends RootPage {
        private void setup(PageParameters params) {\r
                setupPage("", "");\r
                // check to see if we should display a login message\r
-               boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, true);\r
+               boolean authenticateView = app().settings().getBoolean(Keys.web.authenticateViewPages, true);\r
                if (authenticateView && !GitBlitWebSession.get().isLoggedIn()) {\r
-                       String messageSource = GitBlit.getString(Keys.web.loginMessage, "gitblit");\r
+                       String messageSource = app().settings().getString(Keys.web.loginMessage, "gitblit");\r
                        String message = readMarkdown(messageSource, "login.mkd");\r
                        Component repositoriesMessage = new Label("repositoriesMessage", message);\r
                        add(repositoriesMessage.setEscapeModelStrings(false));\r
@@ -74,7 +73,7 @@ public class RepositoriesPage extends RootPage {
                }\r
 \r
                // Load the markdown welcome message\r
-               String messageSource = GitBlit.getString(Keys.web.repositoriesMessage, "gitblit");\r
+               String messageSource = app().settings().getString(Keys.web.repositoriesMessage, "gitblit");\r
                String message = readMarkdown(messageSource, "welcome.mkd");\r
                Component repositoriesMessage = new Label("repositoriesMessage", message)\r
                                .setEscapeModelStrings(false).setVisible(message.length() > 0);\r
@@ -120,7 +119,7 @@ public class RepositoriesPage extends RootPage {
                } else {\r
                        // Read user-supplied message\r
                        if (!StringUtils.isEmpty(messageSource)) {\r
-                               File file = GitBlit.getFileOrFolder(messageSource);\r
+                               File file = app().runtime().getFileOrFolder(messageSource);\r
                                if (file.exists()) {\r
                                        try {\r
                                                FileInputStream fis = new FileInputStream(file);\r
index 93af1bef3af608f891e3abaf99f61272a3ac727d..e19c1955857560bee0cc3cadf7313b85595c6a9c 100644 (file)
@@ -46,7 +46,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;\r
 \r
 import com.gitblit.Constants;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.GitBlitException;\r
 import com.gitblit.Keys;\r
 import com.gitblit.PagesServlet;\r
@@ -60,6 +59,7 @@ import com.gitblit.models.UserRepositoryPreferences;
 import com.gitblit.utils.ArrayUtils;\r
 import com.gitblit.utils.DeepCopier;\r
 import com.gitblit.utils.JGitUtils;\r
+import com.gitblit.utils.MessageProcessor;\r
 import com.gitblit.utils.RefLogUtils;\r
 import com.gitblit.utils.StringUtils;\r
 import com.gitblit.wicket.CacheControl;\r
@@ -97,7 +97,7 @@ public abstract class RepositoryPage extends RootPage {
                repositoryName = WicketUtils.getRepositoryName(params);\r
                String root =StringUtils.getFirstPathElement(repositoryName);\r
                if (StringUtils.isEmpty(root)) {\r
-                       projectName = GitBlit.getString(Keys.web.repositoryRootGroupName, "main");\r
+                       projectName = app().settings().getString(Keys.web.repositoryRootGroupName, "main");\r
                } else {\r
                        projectName = root;\r
                }\r
@@ -139,7 +139,7 @@ public abstract class RepositoryPage extends RootPage {
                                UserRepositoryPreferences prefs = user.getPreferences().getRepositoryPreferences(getRepositoryModel().name);\r
                                prefs.starred = star;\r
                                try {\r
-                                       GitBlit.self().updateUserModel(user.username, user, false);\r
+                                       app().users().updateUserModel(user.username, user, false);\r
                                } catch (GitBlitException e) {\r
                                        logger.error("Failed to update user " + user.username, e);\r
                                        error(getString("gb.failedToUpdateUser"), false);\r
@@ -176,6 +176,10 @@ public abstract class RepositoryPage extends RootPage {
                return getClass();\r
        }\r
 \r
+       protected MessageProcessor messageProcessor() {\r
+               return new MessageProcessor(app().settings());\r
+       }\r
+\r
        private Map<String, PageRegistration> registerPages() {\r
                PageParameters params = null;\r
                if (!StringUtils.isEmpty(repositoryName)) {\r
@@ -198,7 +202,7 @@ public abstract class RepositoryPage extends RootPage {
                pages.put("tree", new PageRegistration("gb.tree", TreePage.class, params));\r
                pages.put("docs", new PageRegistration("gb.docs", DocsPage.class, params, true));\r
                pages.put("compare", new PageRegistration("gb.compare", ComparePage.class, params, true));\r
-               if (GitBlit.getBoolean(Keys.web.allowForking, true)) {\r
+               if (app().settings().getBoolean(Keys.web.allowForking, true)) {\r
                        pages.put("forks", new PageRegistration("gb.forks", ForksPage.class, params, true));\r
                }\r
 \r
@@ -212,11 +216,11 @@ public abstract class RepositoryPage extends RootPage {
 \r
                // Conditionally add edit link\r
                showAdmin = false;\r
-               if (GitBlit.getBoolean(Keys.web.authenticateAdminPages, true)) {\r
-                       boolean allowAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, false);\r
+               if (app().settings().getBoolean(Keys.web.authenticateAdminPages, true)) {\r
+                       boolean allowAdmin = app().settings().getBoolean(Keys.web.allowAdministration, false);\r
                        showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin();\r
                } else {\r
-                       showAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, false);\r
+                       showAdmin = app().settings().getBoolean(Keys.web.allowAdministration, false);\r
                }\r
                isOwner = GitBlitWebSession.get().isLoggedIn()\r
                                && (model.isOwner(GitBlitWebSession.get()\r
@@ -225,13 +229,13 @@ public abstract class RepositoryPage extends RootPage {
        }\r
 \r
        protected boolean allowForkControls() {\r
-               return GitBlit.getBoolean(Keys.web.allowForking, true);\r
+               return app().settings().getBoolean(Keys.web.allowForking, true);\r
        }\r
 \r
        @Override\r
        protected void setupPage(String repositoryName, String pageName) {\r
                String projectName = StringUtils.getFirstPathElement(repositoryName);\r
-               ProjectModel project = GitBlit.self().getProjectModel(projectName);\r
+               ProjectModel project = app().projects().getProjectModel(projectName);\r
                if (project.isUserProject()) {\r
                        // user-as-project\r
                        add(new LinkPanel("projectTitle", null, project.getDisplayName(),\r
@@ -267,7 +271,7 @@ public abstract class RepositoryPage extends RootPage {
                                add(new Label("originRepository").setVisible(false));\r
                        }\r
                } else {\r
-                       RepositoryModel origin = GitBlit.self().getRepositoryModel(model.originRepository);\r
+                       RepositoryModel origin = app().repositories().getRepositoryModel(model.originRepository);\r
                        if (origin == null) {\r
                                // no origin repository\r
                                add(new Label("originRepository").setVisible(false));\r
@@ -311,7 +315,7 @@ public abstract class RepositoryPage extends RootPage {
                        add(new ExternalLink("forkLink", "").setVisible(false));\r
                        add(new ExternalLink("myForkLink", "").setVisible(false));\r
                } else {\r
-                       String fork = GitBlit.self().getFork(user.username, model.name);\r
+                       String fork = app().repositories().getFork(user.username, model.name);\r
                        boolean hasFork = fork != null;\r
                        boolean canFork = user.canFork(model);\r
 \r
@@ -363,7 +367,7 @@ public abstract class RepositoryPage extends RootPage {
 \r
        protected Repository getRepository() {\r
                if (r == null) {\r
-                       Repository r = GitBlit.self().getRepository(repositoryName);\r
+                       Repository r = app().repositories().getRepository(repositoryName);\r
                        if (r == null) {\r
                                error(getString("gb.canNotLoadRepository") + " " + repositoryName, true);\r
                                return null;\r
@@ -375,10 +379,10 @@ public abstract class RepositoryPage extends RootPage {
 \r
        protected RepositoryModel getRepositoryModel() {\r
                if (m == null) {\r
-                       RepositoryModel model = GitBlit.self().getRepositoryModel(\r
+                       RepositoryModel model = app().repositories().getRepositoryModel(\r
                                        GitBlitWebSession.get().getUser(), repositoryName);\r
                        if (model == null) {\r
-                               if (GitBlit.self().hasRepository(repositoryName, true)) {\r
+                               if (app().repositories().hasRepository(repositoryName, true)) {\r
                                        // has repository, but unauthorized\r
                                        authenticationError(getString("gb.unauthorizedAccessForRepository") + " " + repositoryName);\r
                                } else {\r
@@ -450,7 +454,7 @@ public abstract class RepositoryPage extends RootPage {
                        return model;\r
                } else {\r
                        // extract the repository name from the clone url\r
-                       List<String> patterns = GitBlit.getStrings(Keys.git.submoduleUrlPatterns);\r
+                       List<String> patterns = app().settings().getStrings(Keys.git.submoduleUrlPatterns);\r
                        String submoduleName = StringUtils.extractRepositoryPath(model.url, patterns.toArray(new String[0]));\r
 \r
                        // determine the current path for constructing paths relative\r
@@ -489,7 +493,7 @@ public abstract class RepositoryPage extends RootPage {
                        // create a unique, ordered set of candidate paths\r
                        Set<String> paths = new LinkedHashSet<String>(candidates);\r
                        for (String candidate : paths) {\r
-                               if (GitBlit.self().hasRepository(candidate)) {\r
+                               if (app().repositories().hasRepository(candidate)) {\r
                                        model.hasSubmodule = true;\r
                                        model.gitblitPath = candidate;\r
                                        return model;\r
@@ -503,7 +507,7 @@ public abstract class RepositoryPage extends RootPage {
        }\r
 \r
        protected String getShortObjectId(String objectId) {\r
-               return objectId.substring(0, GitBlit.getInteger(Keys.web.shortCommitIdLength, 6));\r
+               return objectId.substring(0, app().settings().getInteger(Keys.web.shortCommitIdLength, 6));\r
        }\r
 \r
        protected void addRefs(Repository r, RevCommit c) {\r
@@ -512,7 +516,7 @@ public abstract class RepositoryPage extends RootPage {
 \r
        protected void addFullText(String wicketId, String text) {\r
                RepositoryModel model = getRepositoryModel();\r
-               String content = GitBlit.self().processCommitMessage(model, text);\r
+               String content = messageProcessor().processCommitMessage(model, text);\r
                String html;\r
                switch (model.commitMessageRenderer) {\r
                case MARKDOWN:\r
@@ -533,7 +537,7 @@ public abstract class RepositoryPage extends RootPage {
                String address = identity == null ? "" : identity.getEmailAddress();\r
                name = StringUtils.removeNewlines(name);\r
                address = StringUtils.removeNewlines(address);\r
-               boolean showEmail = GitBlit.getBoolean(Keys.web.showEmailAddresses, false);\r
+               boolean showEmail = app().settings().getBoolean(Keys.web.showEmailAddresses, false);\r
                if (!showEmail || StringUtils.isEmpty(name) || StringUtils.isEmpty(address)) {\r
                        String value = name;\r
                        if (StringUtils.isEmpty(value)) {\r
@@ -664,7 +668,7 @@ public abstract class RepositoryPage extends RootPage {
                        DropDownChoice<Constants.SearchType> searchType = new DropDownChoice<Constants.SearchType>(\r
                                        "searchType", Arrays.asList(Constants.SearchType.values()));\r
                        searchType.setModel(searchTypeModel);\r
-                       add(searchType.setVisible(GitBlit.getBoolean(Keys.web.showSearchTypeSelection, false)));\r
+                       add(searchType.setVisible(app().settings().getBoolean(Keys.web.showSearchTypeSelection, false)));\r
                        TextField<String> searchBox = new TextField<String>("searchBox", searchBoxModel);\r
                        add(searchBox);\r
                }\r
@@ -695,8 +699,8 @@ public abstract class RepositoryPage extends RootPage {
                                }\r
                        }\r
                        Class<? extends BasePage> searchPageClass = GitSearchPage.class;\r
-                       RepositoryModel model = GitBlit.self().getRepositoryModel(repositoryName);\r
-                       if (GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true)\r
+                       RepositoryModel model = app().repositories().getRepositoryModel(repositoryName);\r
+                       if (app().settings().getBoolean(Keys.web.allowLuceneIndexing, true)\r
                                        && !ArrayUtils.isEmpty(model.indexedBranches)) {\r
                                // this repository is Lucene-indexed\r
                                searchPageClass = LuceneSearchPage.class;\r
index ebe15304d2b11097d323c9b1e1d00d13a2918c31..8aec9e6333096bb32354b099cdfbd8517705b01f 100644 (file)
@@ -23,7 +23,6 @@ import org.apache.wicket.PageParameters;
 import org.apache.wicket.markup.html.basic.Label;\r
 \r
 import com.gitblit.Constants.FederationToken;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.FederationProposal;\r
 import com.gitblit.models.RepositoryModel;\r
@@ -37,14 +36,12 @@ public class ReviewProposalPage extends RootSubPage {
 \r
        private final String PROPS_PATTERN = "{0} = {1}\n";\r
 \r
-       private final String WEBXML_PATTERN = "\n<context-param>\n\t<param-name>{0}</param-name>\n\t<param-value>{1}</param-value>\n</context-param>\n";\r
-\r
        public ReviewProposalPage(PageParameters params) {\r
                super(params);\r
 \r
                final String token = WicketUtils.getToken(params);\r
 \r
-               FederationProposal proposal = GitBlit.self().getPendingFederationProposal(token);\r
+               FederationProposal proposal = app().federation().getPendingFederationProposal(token);\r
                if (proposal == null) {\r
                        error(getString("gb.couldNotFindFederationProposal"), true);\r
                }\r
@@ -58,14 +55,7 @@ public class ReviewProposalPage extends RootSubPage {
                add(new Label("token", proposal.token));\r
                add(new Label("tokenType", proposal.tokenType.name()));\r
 \r
-               String p;\r
-               if (GitBlit.isGO()) {\r
-                       // gitblit.properties definition\r
-                       p = PROPS_PATTERN;\r
-               } else {\r
-                       // web.xml definition\r
-                       p = WEBXML_PATTERN;\r
-               }\r
+               String p = PROPS_PATTERN;\r
 \r
                // build proposed definition\r
                StringBuilder sb = new StringBuilder();\r
@@ -77,7 +67,7 @@ public class ReviewProposalPage extends RootSubPage {
                        sb.append(asParam(p, proposal.name, "mergeAccounts", "false"));\r
                }\r
                sb.append(asParam(p, proposal.name, "frequency",\r
-                               GitBlit.getString(Keys.federation.defaultFrequency, "60 mins")));\r
+                               app().settings().getString(Keys.federation.defaultFrequency, "60 mins")));\r
                sb.append(asParam(p, proposal.name, "folder", proposal.name));\r
                sb.append(asParam(p, proposal.name, "bare", "true"));\r
                sb.append(asParam(p, proposal.name, "mirror", "true"));\r
index a59e2022893074cc5d7f10fd4a0479a85c23db9d..98a8cb3274cce56b1fba1352fa0cefa507ac67fe 100644 (file)
@@ -46,7 +46,6 @@ import org.apache.wicket.model.Model;
 import org.apache.wicket.protocol.http.WebResponse;\r
 \r
 import com.gitblit.Constants;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.TeamModel;\r
@@ -97,22 +96,22 @@ public abstract class RootPage extends BasePage {
                                StringBuilder buffer = new StringBuilder();\r
                                buffer.append("<style type=\"text/css\">\n");\r
                                buffer.append(".navbar-inner {\n");\r
-                               final String headerBackground = GitBlit.getString(Keys.web.headerBackgroundColor, null);\r
+                               final String headerBackground = app().settings().getString(Keys.web.headerBackgroundColor, null);\r
                                if (!StringUtils.isEmpty(headerBackground)) {\r
                                        buffer.append(MessageFormat.format("background-color: {0};\n", headerBackground));\r
                                }\r
-                               final String headerBorder = GitBlit.getString(Keys.web.headerBorderColor, null);\r
+                               final String headerBorder = app().settings().getString(Keys.web.headerBorderColor, null);\r
                                if (!StringUtils.isEmpty(headerBorder)) {\r
                                        buffer.append(MessageFormat.format("border-bottom: 1px solid {0} !important;\n", headerBorder));\r
                                }\r
                                buffer.append("}\n");\r
-                               final String headerBorderFocus = GitBlit.getString(Keys.web.headerBorderFocusColor, null);\r
+                               final String headerBorderFocus = app().settings().getString(Keys.web.headerBorderFocusColor, null);\r
                                if (!StringUtils.isEmpty(headerBorderFocus)) {\r
                                        buffer.append(".navbar ul li:focus, .navbar .active {\n");\r
                                        buffer.append(MessageFormat.format("border-bottom: 4px solid {0};\n", headerBorderFocus));\r
                                        buffer.append("}\n");\r
                                }\r
-                               final String headerForeground = GitBlit.getString(Keys.web.headerForegroundColor, null);\r
+                               final String headerForeground = app().settings().getString(Keys.web.headerForegroundColor, null);\r
                                if (!StringUtils.isEmpty(headerForeground)) {\r
                                        buffer.append(".navbar ul.nav li a {\n");\r
                                        buffer.append(MessageFormat.format("color: {0};\n", headerForeground));\r
@@ -121,7 +120,7 @@ public abstract class RootPage extends BasePage {
                                        buffer.append(MessageFormat.format("color: {0};\n", headerForeground));\r
                                        buffer.append("}\n");\r
                                }\r
-                               final String headerHover = GitBlit.getString(Keys.web.headerHoverColor, null);\r
+                               final String headerHover = app().settings().getString(Keys.web.headerHoverColor, null);\r
                                if (!StringUtils.isEmpty(headerHover)) {\r
                                        buffer.append(".navbar ul.nav li a:hover {\n");\r
                                        buffer.append(MessageFormat.format("color: {0} !important;\n", headerHover));\r
@@ -132,9 +131,9 @@ public abstract class RootPage extends BasePage {
                                }\r
                        }));\r
 \r
-               boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, false);\r
-               boolean authenticateAdmin = GitBlit.getBoolean(Keys.web.authenticateAdminPages, true);\r
-               boolean allowAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, true);\r
+               boolean authenticateView = app().settings().getBoolean(Keys.web.authenticateViewPages, false);\r
+               boolean authenticateAdmin = app().settings().getBoolean(Keys.web.authenticateAdminPages, true);\r
+               boolean allowAdmin = app().settings().getBoolean(Keys.web.allowAdministration, true);\r
 \r
                if (authenticateAdmin) {\r
                        showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin();\r
@@ -163,8 +162,8 @@ public abstract class RootPage extends BasePage {
                        add(new Label("userPanel").setVisible(false));\r
                }\r
 \r
-               boolean showRegistrations = GitBlit.canFederate()\r
-                               && GitBlit.getBoolean(Keys.web.showFederationRegistrations, false);\r
+               boolean showRegistrations = app().federation().canFederate()\r
+                               && app().settings().getBoolean(Keys.web.showFederationRegistrations, false);\r
 \r
                // navigation links\r
                List<PageRegistration> pages = new ArrayList<PageRegistration>();\r
@@ -174,7 +173,7 @@ public abstract class RootPage extends BasePage {
                        pages.add(new PageRegistration("gb.repositories", RepositoriesPage.class,\r
                                        getRootPageParameters()));\r
                        pages.add(new PageRegistration("gb.activity", ActivityPage.class, getRootPageParameters()));\r
-                       if (GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true)) {\r
+                       if (app().settings().getBoolean(Keys.web.allowLuceneIndexing, true)) {\r
                                pages.add(new PageRegistration("gb.search", LuceneSearchPage.class));\r
                        }\r
                        if (showAdmin) {\r
@@ -197,7 +196,7 @@ public abstract class RootPage extends BasePage {
                if (!StringUtils.isEmpty(cachedMessage)) {\r
                        error(cachedMessage);\r
                } else if (showAdmin) {\r
-                       int pendingProposals = GitBlit.self().getPendingFederationProposals().size();\r
+                       int pendingProposals = app().federation().getPendingFederationProposals().size();\r
                        if (pendingProposals == 1) {\r
                                info(getString("gb.OneProposalToReview"));\r
                        } else if (pendingProposals > 1) {\r
@@ -229,7 +228,7 @@ public abstract class RootPage extends BasePage {
 \r
                                // remove days back parameter if it is the default value\r
                                if (params.containsKey("db")\r
-                                               && params.getInt("db") == GitBlit.getInteger(Keys.web.activityDuration, 7)) {\r
+                                               && params.getInt("db") == app().settings().getInteger(Keys.web.activityDuration, 7)) {\r
                                        params.remove("db");\r
                                }\r
                                return params;\r
@@ -251,9 +250,9 @@ public abstract class RootPage extends BasePage {
                        session.setUser(user);\r
 \r
                        // Set Cookie\r
-                       if (GitBlit.getBoolean(Keys.web.allowCookieAuthentication, false)) {\r
+                       if (app().settings().getBoolean(Keys.web.allowCookieAuthentication, false)) {\r
                                WebResponse response = (WebResponse) getRequestCycle().getResponse();\r
-                               GitBlit.self().setCookie(response, user);\r
+                               app().session().setCookie(response, user);\r
                        }\r
 \r
                        if (!session.continueRequest()) {\r
@@ -274,7 +273,7 @@ public abstract class RootPage extends BasePage {
        protected List<RepositoryModel> getRepositoryModels() {\r
                if (repositoryModels.isEmpty()) {\r
                        final UserModel user = GitBlitWebSession.get().getUser();\r
-                       List<RepositoryModel> repositories = GitBlit.self().getRepositoryModels(user);\r
+                       List<RepositoryModel> repositories = app().repositories().getRepositoryModels(user);\r
                        repositoryModels.addAll(repositories);\r
                        Collections.sort(repositoryModels);\r
                }\r
@@ -326,7 +325,7 @@ public abstract class RootPage extends BasePage {
                }\r
 \r
                // custom filters\r
-               String customFilters = GitBlit.getString(Keys.web.customFilters, null);\r
+               String customFilters = app().settings().getString(Keys.web.customFilters, null);\r
                if (!StringUtils.isEmpty(customFilters)) {\r
                        boolean addedExpression = false;\r
                        List<String> expressions = StringUtils.getStringsFromValue(customFilters, "!!!");\r
@@ -346,8 +345,8 @@ public abstract class RootPage extends BasePage {
 \r
        protected List<DropDownMenuItem> getTimeFilterItems(PageParameters params) {\r
                // days back choices - additive parameters\r
-               int daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);\r
-               int maxDaysBack = GitBlit.getInteger(Keys.web.activityDurationMaximum, 30);\r
+               int daysBack = app().settings().getInteger(Keys.web.activityDuration, 7);\r
+               int maxDaysBack = app().settings().getInteger(Keys.web.activityDurationMaximum, 30);\r
                if (daysBack < 1) {\r
                        daysBack = 7;\r
                }\r
@@ -366,7 +365,7 @@ public abstract class RootPage extends BasePage {
                }\r
 \r
                List<DropDownMenuItem> items = new ArrayList<DropDownMenuItem>();\r
-               Set<Integer> choicesSet = new TreeSet<Integer>(GitBlit.getIntegers(Keys.web.activityDurationChoices));\r
+               Set<Integer> choicesSet = new TreeSet<Integer>(app().settings().getIntegers(Keys.web.activityDurationChoices));\r
                if (choicesSet.isEmpty()) {\r
                         choicesSet.addAll(Arrays.asList(1, 3, 7, 14, 21, 28));\r
                }\r
@@ -403,7 +402,7 @@ public abstract class RootPage extends BasePage {
                String regex = WicketUtils.getRegEx(params);\r
                String team = WicketUtils.getTeam(params);\r
                int daysBack = params.getInt("db", 0);\r
-               int maxDaysBack = GitBlit.getInteger(Keys.web.activityDurationMaximum, 30);\r
+               int maxDaysBack = app().settings().getInteger(Keys.web.activityDurationMaximum, 30);\r
 \r
                List<RepositoryModel> availableModels = getRepositoryModels();\r
                Set<RepositoryModel> models = new HashSet<RepositoryModel>();\r
@@ -422,7 +421,7 @@ public abstract class RootPage extends BasePage {
                if (!StringUtils.isEmpty(projectName)) {\r
                        // try named project\r
                        hasParameter = true;\r
-                       if (projectName.equalsIgnoreCase(GitBlit.getString(Keys.web.repositoryRootGroupName, "main"))) {\r
+                       if (projectName.equalsIgnoreCase(app().settings().getString(Keys.web.repositoryRootGroupName, "main"))) {\r
                                // root project/group\r
                                for (RepositoryModel model : availableModels) {\r
                                        if (model.name.indexOf('/') == -1) {\r
@@ -472,7 +471,7 @@ public abstract class RootPage extends BasePage {
                        // need TeamModels first\r
                        List<TeamModel> teamModels = new ArrayList<TeamModel>();\r
                        for (String name : teams) {\r
-                               TeamModel teamModel = GitBlit.self().getTeamModel(name);\r
+                               TeamModel teamModel = app().users().getTeamModel(name);\r
                                if (teamModel != null) {\r
                                        teamModels.add(teamModel);\r
                                }\r
@@ -537,7 +536,7 @@ public abstract class RootPage extends BasePage {
                                        String username = RootPage.this.username.getObject();\r
                                        char[] password = RootPage.this.password.getObject().toCharArray();\r
 \r
-                                       UserModel user = GitBlit.self().authenticate(username, password);\r
+                                       UserModel user = app().session().authenticate(username, password);\r
                                        if (user == null) {\r
                                                error(getString("gb.invalidUsernameOrPassword"));\r
                                        } else if (user.username.equals(Constants.FEDERATION_USER)) {\r
@@ -563,7 +562,7 @@ public abstract class RootPage extends BasePage {
        /**\r
         * Menu for the authenticated user.\r
         */\r
-       static class UserMenu extends Fragment {\r
+       class UserMenu extends Fragment {\r
 \r
                private static final long serialVersionUID = 1L;\r
 \r
@@ -573,10 +572,10 @@ public abstract class RootPage extends BasePage {
 \r
                        GitBlitWebSession session = GitBlitWebSession.get();\r
                        UserModel user = session.getUser();\r
-                       boolean editCredentials = GitBlit.self().supportsCredentialChanges(user);\r
+                       boolean editCredentials = app().users().supportsCredentialChanges(user);\r
                        boolean standardLogin = session.authenticationType.isStandard();\r
 \r
-                       if (GitBlit.getBoolean(Keys.web.allowGravatar, true)) {\r
+                       if (app().settings().getBoolean(Keys.web.allowGravatar, true)) {\r
                                add(new GravatarImage("username", user.getDisplayName(),\r
                                                user.emailAddress, "navbarGravatar", 20, false, false));\r
                        } else {\r
index e81717a17fe04c3f6ddcdca80c367a77ecc2cec9..62d07a7f81815c63f0e1a91d8c37d335f51cff13 100644 (file)
@@ -24,7 +24,6 @@ import org.apache.wicket.markup.html.basic.Label;
 \r
 import com.gitblit.Constants.AccessRestrictionType;\r
 import com.gitblit.Constants.AuthorizationControl;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.UserModel;\r
 import com.gitblit.utils.ModelUtils;\r
@@ -86,8 +85,8 @@ public abstract class RootSubPage extends RootPage {
                        }\r
                }\r
 \r
-               for (String repo : GitBlit.self().getRepositoryList()) {\r
-                       RepositoryModel repositoryModel = GitBlit.self().getRepositoryModel(repo);\r
+               for (String repo : app().repositories().getRepositoryList()) {\r
+                       RepositoryModel repositoryModel = app().repositories().getRepositoryModel(repo);\r
                        if (repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE)\r
                                        && repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED)) {\r
                                if (user != null &&\r
index b1a8c5b6132827006f796db2b1eee696467e1be1..9ccf1aa2ee7a5fd9d7e9ed9c7b4a4ccc5c64a75c 100644 (file)
@@ -27,7 +27,6 @@ import org.apache.wicket.markup.html.form.TextField;
 import org.apache.wicket.model.CompoundPropertyModel;\r
 \r
 import com.gitblit.Constants.FederationProposalResult;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.models.FederationProposal;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.utils.FederationUtils;\r
@@ -57,7 +56,7 @@ public class SendProposalPage extends RootSubPage {
                destinationUrl = "https://";\r
 \r
                // temporary proposal\r
-               FederationProposal proposal = GitBlit.self().createFederationProposal(myUrl, token);\r
+               FederationProposal proposal = app().federation().createFederationProposal(myUrl, token);\r
                if (proposal == null) {\r
                        error(getString("gb.couldNotCreateFederationProposal"), true);\r
                }\r
@@ -81,7 +80,7 @@ public class SendProposalPage extends RootSubPage {
                                }\r
 \r
                                // build new proposal\r
-                               FederationProposal proposal = GitBlit.self().createFederationProposal(myUrl, token);\r
+                               FederationProposal proposal = app().federation().createFederationProposal(myUrl, token);\r
                                proposal.url = myUrl;\r
                                proposal.message = message;\r
                                try {\r
index 5a255ec524c75def1ec033fbb40bae718c8e3954..886dd6e683a94d5ceca39e5444ea16435e79cd1d 100644 (file)
@@ -22,8 +22,9 @@ import org.apache.wicket.markup.html.WebPage;
 import org.apache.wicket.protocol.http.WebRequest;\r
 import org.apache.wicket.protocol.http.WebResponse;\r
 \r
-import com.gitblit.GitBlit;\r
+import com.gitblit.Keys;\r
 import com.gitblit.models.UserModel;\r
+import com.gitblit.wicket.GitBlitWebApp;\r
 import com.gitblit.wicket.GitBlitWebSession;\r
 \r
 public abstract class SessionPage extends WebPage {\r
@@ -38,12 +39,20 @@ public abstract class SessionPage extends WebPage {
                login();\r
        }\r
 \r
+       protected String [] getEncodings() {\r
+               return app().settings().getStrings(Keys.web.blobEncodings).toArray(new String[0]);\r
+       }\r
+\r
+       protected GitBlitWebApp app() {\r
+               return GitBlitWebApp.get();\r
+       }\r
+\r
        private void login() {\r
                GitBlitWebSession session = GitBlitWebSession.get();\r
                if (session.isLoggedIn() && !session.isSessionInvalidated()) {\r
                        // already have a session, refresh usermodel to pick up\r
                        // any changes to permissions or roles (issue-186)\r
-                       UserModel user = GitBlit.self().getUserModel(session.getUser().username);\r
+                       UserModel user = app().users().getUserModel(session.getUser().username);\r
                        session.setUser(user);\r
                        return;\r
                }\r
@@ -51,7 +60,7 @@ public abstract class SessionPage extends WebPage {
                // try to authenticate by servlet request\r
                HttpServletRequest httpRequest = ((WebRequest) getRequestCycle().getRequest())\r
                                .getHttpServletRequest();\r
-               UserModel user = GitBlit.self().authenticate(httpRequest);\r
+               UserModel user = app().session().authenticate(httpRequest);\r
 \r
                // Login the user\r
                if (user != null) {\r
@@ -61,7 +70,7 @@ public abstract class SessionPage extends WebPage {
 \r
                        // Set Cookie\r
                        WebResponse response = (WebResponse) getRequestCycle().getResponse();\r
-                       GitBlit.self().setCookie(response, user);\r
+                       app().session().setCookie(response, user);\r
 \r
                        session.continueRequest();\r
                }\r
index 5604be4e4c6e2976e2f8400ca53c3a6c6a6b6cc5..9129302b9bfaa416b3b8a6d03c552fbc02dd946f 100644 (file)
@@ -40,7 +40,6 @@ import org.wicketstuff.googlecharts.LineStyle;
 import org.wicketstuff.googlecharts.MarkerType;\r
 import org.wicketstuff.googlecharts.ShapeMarker;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.Metric;\r
 import com.gitblit.models.RepositoryModel;\r
@@ -67,11 +66,11 @@ public class SummaryPage extends RepositoryPage {
        public SummaryPage(PageParameters params) {\r
                super(params);\r
 \r
-               int numberCommits = GitBlit.getInteger(Keys.web.summaryCommitCount, 20);\r
+               int numberCommits = app().settings().getInteger(Keys.web.summaryCommitCount, 20);\r
                if (numberCommits <= 0) {\r
                        numberCommits = 20;\r
                }\r
-               int numberRefs = GitBlit.getInteger(Keys.web.summaryRefsCount, 5);\r
+               int numberRefs = app().settings().getInteger(Keys.web.summaryRefsCount, 5);\r
 \r
                Repository r = getRepository();\r
                final RepositoryModel model = getRepositoryModel();\r
@@ -82,8 +81,8 @@ public class SummaryPage extends RepositoryPage {
 \r
                List<Metric> metrics = null;\r
                Metric metricsTotal = null;\r
-               if (!model.skipSummaryMetrics && GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {\r
-                       metrics = GitBlit.self().getRepositoryDefaultMetrics(model, r);\r
+               if (!model.skipSummaryMetrics && app().settings().getBoolean(Keys.web.generateActivityGraph, true)) {\r
+                       metrics = app().repositories().getRepositoryDefaultMetrics(model, r);\r
                        metricsTotal = metrics.remove(0);\r
                }\r
 \r
@@ -101,7 +100,7 @@ public class SummaryPage extends RepositoryPage {
                        @Override\r
                        public void populateItem(final Item<String> item) {\r
                                String ownername = item.getModelObject();\r
-                               UserModel ownerModel = GitBlit.self().getUserModel(ownername);\r
+                               UserModel ownerModel = app().users().getUserModel(ownername);\r
                                if (ownerModel != null) {\r
                                        item.add(new LinkPanel("owner", null, ownerModel.getDisplayName(), UserPage.class,\r
                                                        WicketUtils.newUsernameParameter(ownerModel.username)).setRenderBodyOnly(true));\r
@@ -138,10 +137,10 @@ public class SummaryPage extends RepositoryPage {
                add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs).hideIfEmpty());\r
                add(new BranchesPanel("branchesPanel", getRepositoryModel(), r, numberRefs, false).hideIfEmpty());\r
 \r
-               if (GitBlit.getBoolean(Keys.web.summaryShowReadme, false)) {\r
+               if (app().settings().getBoolean(Keys.web.summaryShowReadme, false)) {\r
                        // show a readme on the summary page\r
                        RevCommit head = JGitUtils.getCommit(r, null);\r
-                       MarkupProcessor processor = new MarkupProcessor(GitBlit.getSettings());\r
+                       MarkupProcessor processor = new MarkupProcessor(app().settings());\r
                        MarkupDocument markupDoc = processor.getReadme(r, repositoryName, getBestCommitId(head));\r
                        if (markupDoc == null || markupDoc.markup == null) {\r
                                add(new Label("readme").setVisible(false));\r
@@ -169,7 +168,7 @@ public class SummaryPage extends RepositoryPage {
 \r
        private void insertActivityGraph(List<Metric> metrics) {\r
                if ((metrics != null) && (metrics.size() > 0)\r
-                               && GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {\r
+                               && app().settings().getBoolean(Keys.web.generateActivityGraph, true)) {\r
                        IChartData data = WicketUtils.getChartData(metrics);\r
 \r
                        ChartProvider provider = new ChartProvider(new Dimension(290, 100), ChartType.LINE,\r
index 4b62e797b37b6a3d489103484534acc29a20def2..1e5ddcf08764f39525deb5aef61087c7028324d1 100644 (file)
@@ -28,7 +28,6 @@ import org.apache.wicket.markup.repeater.data.DataView;
 import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
 import org.eclipse.jgit.lib.PersonIdent;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.ProjectModel;\r
 import com.gitblit.models.RepositoryModel;\r
@@ -67,7 +66,7 @@ public class UserPage extends RootPage {
        private void setup(PageParameters params) {\r
                setupPage("", "");\r
                // check to see if we should display a login message\r
-               boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, true);\r
+               boolean authenticateView = app().settings().getBoolean(Keys.web.authenticateViewPages, true);\r
                if (authenticateView && !GitBlitWebSession.get().isLoggedIn()) {\r
                        authenticationError("Please login");\r
                        return;\r
@@ -78,7 +77,7 @@ public class UserPage extends RootPage {
                        throw new GitblitRedirectException(GitBlitWebApp.get().getHomePage());\r
                }\r
 \r
-               UserModel user = GitBlit.self().getUserModel(userName);\r
+               UserModel user = app().users().getUserModel(userName);\r
                if (user == null) {\r
                        // construct a temporary user model\r
                        user = new UserModel(userName);\r
@@ -86,7 +85,7 @@ public class UserPage extends RootPage {
 \r
                String projectName = user.getPersonalPath();\r
 \r
-               ProjectModel project = GitBlit.self().getProjectModel(projectName);\r
+               ProjectModel project = app().projects().getProjectModel(projectName);\r
                if (project == null) {\r
                        project = new ProjectModel(projectName);\r
                }\r
@@ -95,7 +94,7 @@ public class UserPage extends RootPage {
                add(new Label("userUsername", user.username));\r
                LinkPanel email = new LinkPanel("userEmail", null, user.emailAddress, "mailto:#");\r
                email.setRenderBodyOnly(true);\r
-               add(email.setVisible(GitBlit.getBoolean(Keys.web.showEmailAddresses, true) && !StringUtils.isEmpty(user.emailAddress)));\r
+               add(email.setVisible(app().settings().getBoolean(Keys.web.showEmailAddresses, true) && !StringUtils.isEmpty(user.emailAddress)));\r
 \r
                PersonIdent person = new PersonIdent(user.getDisplayName(), user.emailAddress == null ? user.getDisplayName() : user.emailAddress);\r
                add(new GravatarImage("gravatar", person, 210));\r
index e5c8e46466b7972e1de8eea897c020af71f3b37b..bbb7608d7e472377322768a2d8767457fff30734 100644 (file)
@@ -25,7 +25,6 @@ import org.apache.wicket.markup.repeater.data.ListDataProvider;
 import org.eclipse.jgit.lib.Repository;\r
 \r
 import com.gitblit.Constants;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.Activity;\r
 import com.gitblit.models.RepositoryCommit;\r
@@ -53,7 +52,7 @@ public class ActivityPanel extends BasePanel {
 \r
                Collections.sort(recentActivity);\r
 \r
-               final int shortHashLen = GitBlit.getInteger(Keys.web.shortCommitIdLength, 6);\r
+               final int shortHashLen = app().settings().getInteger(Keys.web.shortCommitIdLength, 6);\r
                DataView<Activity> activityView = new DataView<Activity>("activity",\r
                                new ListDataProvider<Activity>(recentActivity)) {\r
                        private static final long serialVersionUID = 1L;\r
index b60579b7349c67edc7c68786ce5600cfc3655f5e..dda579791c947cdbb21c7d5629b090c7fbfbee43 100644 (file)
@@ -24,9 +24,9 @@ import org.apache.wicket.markup.html.panel.Panel;
 import org.apache.wicket.model.Model;\r
 \r
 import com.gitblit.Constants;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.utils.TimeUtils;\r
+import com.gitblit.wicket.GitBlitWebApp;\r
 import com.gitblit.wicket.GitBlitWebSession;\r
 import com.gitblit.wicket.WicketUtils;\r
 \r
@@ -40,9 +40,13 @@ public abstract class BasePanel extends Panel {
                super(wicketId);\r
        }\r
 \r
+       protected GitBlitWebApp app() {\r
+               return GitBlitWebApp.get();\r
+       }\r
+\r
        protected TimeZone getTimeZone() {\r
-               return GitBlit.getBoolean(Keys.web.useClientTimezone, false) ? GitBlitWebSession.get()\r
-                               .getTimezone() : GitBlit.getTimezone();\r
+               return app().settings().getBoolean(Keys.web.useClientTimezone, false) ? GitBlitWebSession.get()\r
+                               .getTimezone() : app().getTimezone();\r
        }\r
 \r
        protected TimeUtils getTimeUtils() {\r
index 4981c8b2a0f76ead22c6f57717351b1f06dd591a..7fec0eae17571143bdc35ff4cb972a67ff1ab8f5 100644 (file)
@@ -37,7 +37,6 @@ import org.eclipse.jgit.lib.Ref;
 import org.eclipse.jgit.lib.Repository;\r
 \r
 import com.gitblit.Constants;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.SyndicationServlet;\r
 import com.gitblit.models.RefModel;\r
 import com.gitblit.models.RepositoryModel;\r
@@ -190,9 +189,9 @@ public class BranchesPanel extends BasePanel {
 \r
                        @Override\r
                        public void onClick() {\r
-                               Repository r = GitBlit.self().getRepository(repositoryModel.name);\r
+                               Repository r = app().repositories().getRepository(repositoryModel.name);\r
                                if (r == null) {\r
-                                       if (GitBlit.self().isCollectingGarbage(repositoryModel.name)) {\r
+                                       if (app().repositories().isCollectingGarbage(repositoryModel.name)) {\r
                                                error(MessageFormat.format(getString("gb.busyCollectingGarbage"), repositoryModel.name));\r
                                        } else {\r
                                                error(MessageFormat.format("Failed to find repository {0}", repositoryModel.name));\r
index d8a4a106fa05fad7a38ba26847340f5b4dc876da..72a032e008477eec640a6481fd4b98ea08200b4b 100644 (file)
@@ -18,24 +18,22 @@ package com.gitblit.wicket.panels;
 import java.util.List;\r
 \r
 import org.apache.wicket.markup.html.basic.Label;\r
-import org.apache.wicket.markup.html.panel.Panel;\r
 import org.apache.wicket.markup.repeater.Item;\r
 import org.apache.wicket.markup.repeater.data.DataView;\r
 import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
 \r
 import com.gitblit.DownloadZipServlet;\r
 import com.gitblit.DownloadZipServlet.Format;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 \r
-public class CompressedDownloadsPanel extends Panel {\r
+public class CompressedDownloadsPanel extends BasePanel {\r
 \r
        private static final long serialVersionUID = 1L;\r
 \r
        public CompressedDownloadsPanel(String id, final String baseUrl, final String repositoryName, final String objectId, final String path) {\r
                super(id);\r
 \r
-               List<String> types = GitBlit.getStrings(Keys.web.compressedDownloads);\r
+               List<String> types = app().settings().getStrings(Keys.web.compressedDownloads);\r
                if (types.isEmpty()) {\r
                        types.add(Format.zip.name());\r
                        types.add(Format.gz.name());\r
@@ -72,6 +70,6 @@ public class CompressedDownloadsPanel extends Panel {
                };\r
                add(refsView);\r
 \r
-               setVisible(GitBlit.getBoolean(Keys.web.allowZipDownloads, true));\r
+               setVisible(app().settings().getBoolean(Keys.web.allowZipDownloads, true));\r
        }\r
 }
\ No newline at end of file
index 10d5d1b3780f9fe69dd9357f8d1f07b368387f46..318e74c29a6558eaa86c83b83afbead0146bf822 100644 (file)
@@ -31,7 +31,6 @@ import org.apache.wicket.markup.repeater.data.ListDataProvider;
 import org.eclipse.jgit.lib.PersonIdent;\r
 \r
 import com.gitblit.Constants;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.DailyLogEntry;\r
 import com.gitblit.models.RepositoryCommit;\r
@@ -56,9 +55,9 @@ public class DigestsPanel extends BasePanel {
                super(wicketId);\r
                hasChanges = digests.size() > 0;\r
 \r
-               final int hashLen = GitBlit.getInteger(Keys.web.shortCommitIdLength, 6);\r
+               final int hashLen = app().settings().getInteger(Keys.web.shortCommitIdLength, 6);\r
 \r
-               String dateFormat = GitBlit.getString(Keys.web.datestampLongFormat, "EEEE, MMMM d, yyyy");\r
+               String dateFormat = app().settings().getString(Keys.web.datestampLongFormat, "EEEE, MMMM d, yyyy");\r
                final TimeZone timezone = getTimeZone();\r
                final DateFormat df = new SimpleDateFormat(dateFormat);\r
                df.setTimeZone(timezone);\r
@@ -203,7 +202,7 @@ public class DigestsPanel extends BasePanel {
                                        logItem.add(new LinkPanel("compareLink", null, compareLinkText, ComparePage.class, WicketUtils.newRangeParameter(change.repository, startRangeId, endRangeId)));\r
                                }\r
 \r
-                               final boolean showSwatch = GitBlit.getBoolean(Keys.web.repositoryListSwatches, true);\r
+                               final boolean showSwatch = app().settings().getBoolean(Keys.web.repositoryListSwatches, true);\r
 \r
                                ListDataProvider<RepositoryCommit> cdp = new ListDataProvider<RepositoryCommit>(commits);\r
                                DataView<RepositoryCommit> commitsView = new DataView<RepositoryCommit>("commit", cdp) {\r
index c15a0a5cfbbdf2f01c757ac363b1e9e2d71d477f..b02e848ea6e656579de9e7da3781e9f03de7535c 100644 (file)
@@ -25,7 +25,6 @@ import org.apache.wicket.markup.repeater.Item;
 import org.apache.wicket.markup.repeater.data.DataView;\r
 import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.models.FederationProposal;\r
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.pages.ReviewProposalPage;\r
@@ -39,7 +38,7 @@ public class FederationProposalsPanel extends BasePanel {
        public FederationProposalsPanel(String wicketId) {\r
                super(wicketId);\r
 \r
-               final List<FederationProposal> list = GitBlit.self().getPendingFederationProposals();\r
+               final List<FederationProposal> list = app().federation().getPendingFederationProposals();\r
                hasProposals = list.size() > 0;\r
                DataView<FederationProposal> dataView = new DataView<FederationProposal>("row",\r
                                new ListDataProvider<FederationProposal>(list)) {\r
@@ -68,7 +67,7 @@ public class FederationProposalsPanel extends BasePanel {
 \r
                                        @Override\r
                                        public void onClick() {\r
-                                               if (GitBlit.self().deletePendingFederationProposal(entry)) {\r
+                                               if (app().federation().deletePendingFederationProposal(entry)) {\r
                                                        list.remove(entry);\r
                                                        info(MessageFormat.format("Proposal ''{0}'' deleted.", entry.name));\r
                                                } else {\r
index 344af49d8e10330e11ff04055f7430be0007b7ce..264d40d43ed506daed81eb59a864980d8921fe6e 100644 (file)
@@ -25,7 +25,6 @@ import org.apache.wicket.markup.repeater.Item;
 import org.apache.wicket.markup.repeater.data.DataView;\r
 import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.models.FederationModel;\r
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.pages.FederationRegistrationPage;\r
@@ -39,9 +38,9 @@ public class FederationRegistrationsPanel extends BasePanel {
        public FederationRegistrationsPanel(String wicketId) {\r
                super(wicketId);\r
 \r
-               final List<FederationModel> list = new ArrayList<FederationModel>(GitBlit.self()\r
+               final List<FederationModel> list = new ArrayList<FederationModel>(app().federation()\r
                                .getFederationRegistrations());\r
-               list.addAll(GitBlit.self().getFederationResultRegistrations());\r
+               list.addAll(app().federation().getFederationResultRegistrations());\r
                Collections.sort(list);\r
                hasRegistrations = list.size() > 0;\r
                DataView<FederationModel> dataView = new DataView<FederationModel>("row",\r
index afe553c57b495e46d5ac36b9494f96c8962fd2a9..0bad71d4254ccb405130db9e08f00b8f104a5989 100644 (file)
@@ -28,7 +28,6 @@ import org.apache.wicket.markup.repeater.data.ListDataProvider;
 \r
 import com.gitblit.Constants.FederationRequest;\r
 import com.gitblit.Constants.FederationToken;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.utils.FederationUtils;\r
 import com.gitblit.wicket.WicketUtils;\r
@@ -42,22 +41,22 @@ public class FederationTokensPanel extends BasePanel {
                super(wicketId);\r
 \r
                final String baseUrl = WicketUtils.getGitblitURL(getRequest());\r
-               add(new ExternalLink("federatedUsers", FederationUtils.asLink(baseUrl, GitBlit.self()\r
+               add(new ExternalLink("federatedUsers", FederationUtils.asLink(baseUrl, app().federation()\r
                                .getFederationToken(FederationToken.USERS_AND_REPOSITORIES),\r
                                FederationRequest.PULL_USERS)));\r
 \r
-               add(new ExternalLink("federatedSettings", FederationUtils.asLink(baseUrl, GitBlit\r
-                               .self().getFederationToken(FederationToken.ALL), FederationRequest.PULL_SETTINGS)));\r
+               add(new ExternalLink("federatedSettings", FederationUtils.asLink(baseUrl, app().federation()\r
+                               .getFederationToken(FederationToken.ALL), FederationRequest.PULL_SETTINGS)));\r
 \r
                final List<String[]> data = new ArrayList<String[]>();\r
                for (FederationToken token : FederationToken.values()) {\r
-                       data.add(new String[] { token.name(), GitBlit.self().getFederationToken(token), null });\r
+                       data.add(new String[] { token.name(), app().federation().getFederationToken(token), null });\r
                }\r
-               List<String> sets = GitBlit.getStrings(Keys.federation.sets);\r
+               List<String> sets = app().settings().getStrings(Keys.federation.sets);\r
                Collections.sort(sets);\r
                for (String set : sets) {\r
                        data.add(new String[] { FederationToken.REPOSITORIES.name(),\r
-                                       GitBlit.self().getFederationToken(set), set });\r
+                                       app().federation().getFederationToken(set), set });\r
                }\r
 \r
                DataView<String[]> dataView = new DataView<String[]>("row", new ListDataProvider<String[]>(\r
index 4c579264f3b1978e5a9dd6e3d232619d0fc4fa01..3a269a93919900ffaf7c853b968aa147a3e1aee3 100644 (file)
@@ -29,7 +29,6 @@ import java.util.Map;
 import org.apache.wicket.behavior.HeaderContributor;\r
 import org.apache.wicket.markup.html.basic.Label;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.ProjectModel;\r
 import com.gitblit.utils.StringUtils;\r
@@ -93,7 +92,7 @@ public class FilterableProjectList extends BasePanel {
                        panel.add(icon);\r
                }\r
 \r
-               String format = GitBlit.getString(Keys.web.datestampShortFormat, "MM/dd/yy");\r
+               String format = app().settings().getString(Keys.web.datestampShortFormat, "MM/dd/yy");\r
                final DateFormat df = new SimpleDateFormat(format);\r
                df.setTimeZone(getTimeZone());\r
                Collections.sort(projects, new Comparator<ProjectModel>() {\r
index d68155e7183c0d98894e85332569967adcf59aa9..45b0bab1d93d4744b225e9cd6b069ccd04c0ce1b 100644 (file)
@@ -27,7 +27,6 @@ import java.util.Map;
 import org.apache.wicket.behavior.HeaderContributor;\r
 import org.apache.wicket.markup.html.basic.Label;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.utils.StringUtils;\r
@@ -104,7 +103,7 @@ public class FilterableRepositoryList extends BasePanel {
                        panel.add(new Label(ngList + "Button").setVisible(false));\r
                }\r
 \r
-               String format = GitBlit.getString(Keys.web.datestampShortFormat, "MM/dd/yy");\r
+               String format = app().settings().getString(Keys.web.datestampShortFormat, "MM/dd/yy");\r
                final DateFormat df = new SimpleDateFormat(format);\r
                df.setTimeZone(getTimeZone());\r
 \r
@@ -123,7 +122,7 @@ public class FilterableRepositoryList extends BasePanel {
                        item.p = path;\r
                        item.r = repo.name;\r
                        item.i = repo.description;\r
-                       item.s = GitBlit.self().getStarCount(repo);\r
+                       item.s = app().repositories().getStarCount(repo);\r
                        item.t = getTimeUtils().timeAgo(repo.lastChange);\r
                        item.d = df.format(repo.lastChange);\r
                        item.c = StringUtils.getColor(StringUtils.stripDotGit(repo.name));\r
index 741328c3605d8b150f8040564381f4ec47b543c9..34af2bfba9642c35f99205cf6d7e235e814a09c3 100644 (file)
@@ -20,10 +20,8 @@ import java.text.MessageFormat;
 import org.apache.wicket.behavior.SimpleAttributeModifier;\r
 import org.apache.wicket.markup.html.link.BookmarkablePageLink;\r
 import org.apache.wicket.markup.html.link.Link;\r
-import org.apache.wicket.markup.html.panel.Panel;\r
 import org.eclipse.jgit.lib.PersonIdent;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.utils.ActivityUtils;\r
 import com.gitblit.utils.StringUtils;\r
@@ -37,7 +35,7 @@ import com.gitblit.wicket.pages.GravatarProfilePage;
  * @author James Moger\r
  *\r
  */\r
-public class GravatarImage extends Panel {\r
+public class GravatarImage extends BasePanel {\r
 \r
        private static final long serialVersionUID = 1L;\r
 \r
@@ -79,6 +77,6 @@ public class GravatarImage extends Panel {
                        WicketUtils.setHtmlTooltip(link, username);\r
                }\r
                add(link.setEnabled(linked));\r
-               setVisible(GitBlit.getBoolean(Keys.web.allowGravatar, true));\r
+               setVisible(app().settings().getBoolean(Keys.web.allowGravatar, true));\r
        }\r
 }
\ No newline at end of file
index 10a8b570a2cccc793491cb58246d0fdd707be962..ecdad523946bf4dd3f9077acfb5156cc1f1191d5 100644 (file)
@@ -39,7 +39,6 @@ import org.eclipse.jgit.treewalk.TreeWalk;
 import org.eclipse.jgit.treewalk.filter.PathFilterGroup;\r
 \r
 import com.gitblit.Constants;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.PathModel;\r
 import com.gitblit.models.PathModel.PathChangeModel;\r
@@ -66,7 +65,7 @@ public class HistoryPanel extends BasePanel {
                        final String path, Repository r, int limit, int pageOffset, boolean showRemoteRefs) {\r
                super(wicketId);\r
                boolean pageResults = limit <= 0;\r
-               int itemsPerPage = GitBlit.getInteger(Keys.web.itemsPerPage, 50);\r
+               int itemsPerPage = app().settings().getInteger(Keys.web.itemsPerPage, 50);\r
                if (itemsPerPage <= 1) {\r
                        itemsPerPage = 50;\r
                }\r
@@ -143,7 +142,7 @@ public class HistoryPanel extends BasePanel {
                // breadcrumbs\r
                add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, path, objectId));\r
 \r
-               final int hashLen = GitBlit.getInteger(Keys.web.shortCommitIdLength, 6);\r
+               final int hashLen = app().settings().getInteger(Keys.web.shortCommitIdLength, 6);\r
                ListDataProvider<RevCommit> dp = new ListDataProvider<RevCommit>(commits);\r
                DataView<RevCommit> logView = new DataView<RevCommit>("commit", dp) {\r
                        private static final long serialVersionUID = 1L;\r
@@ -205,7 +204,7 @@ public class HistoryPanel extends BasePanel {
                                        item.add(links);\r
                                } else if (isSubmodule) {\r
                                        // submodule\r
-                                       Repository repository = GitBlit.self().getRepository(repositoryName);\r
+                                       Repository repository = app().repositories().getRepository(repositoryName);\r
                                        String submoduleId = JGitUtils.getSubmoduleCommitId(repository, path, entry);\r
                                        repository.close();\r
                                        if (StringUtils.isEmpty(submoduleId)) {\r
@@ -288,7 +287,7 @@ public class HistoryPanel extends BasePanel {
                        return model;\r
                } else {\r
                        // extract the repository name from the clone url\r
-                       List<String> patterns = GitBlit.getStrings(Keys.git.submoduleUrlPatterns);\r
+                       List<String> patterns = app().settings().getStrings(Keys.git.submoduleUrlPatterns);\r
                        String submoduleName = StringUtils.extractRepositoryPath(model.url, patterns.toArray(new String[0]));\r
 \r
                        // determine the current path for constructing paths relative\r
@@ -327,7 +326,7 @@ public class HistoryPanel extends BasePanel {
                        // create a unique, ordered set of candidate paths\r
                        Set<String> paths = new LinkedHashSet<String>(candidates);\r
                        for (String candidate : paths) {\r
-                               if (GitBlit.self().hasRepository(candidate)) {\r
+                               if (app().repositories().hasRepository(candidate)) {\r
                                        model.hasSubmodule = true;\r
                                        model.gitblitPath = candidate;\r
                                        return model;\r
index eba0dd3b4968760cd011db587e25f9500b0f5794..7c91d22d073f8a9ab117ec097db7a5b61c733f23 100644 (file)
@@ -34,7 +34,6 @@ import org.eclipse.jgit.revwalk.RevCommit;
 \r
 import com.gitblit.BranchGraphServlet;\r
 import com.gitblit.Constants;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.RefModel;\r
 import com.gitblit.utils.JGitUtils;\r
@@ -57,7 +56,7 @@ public class LogPanel extends BasePanel {
                        Repository r, int limit, int pageOffset, boolean showRemoteRefs) {\r
                super(wicketId);\r
                boolean pageResults = limit <= 0;\r
-               int itemsPerPage = GitBlit.getInteger(Keys.web.itemsPerPage, 50);\r
+               int itemsPerPage = app().settings().getInteger(Keys.web.itemsPerPage, 50);\r
                if (itemsPerPage <= 1) {\r
                        itemsPerPage = 50;\r
                }\r
@@ -77,7 +76,7 @@ public class LogPanel extends BasePanel {
                hasMore = commits.size() >= itemsPerPage;\r
 \r
                final String baseUrl = WicketUtils.getGitblitURL(getRequest());\r
-               final boolean showGraph = GitBlit.getBoolean(Keys.web.showBranchGraph, true);\r
+               final boolean showGraph = app().settings().getBoolean(Keys.web.showBranchGraph, true);\r
 \r
                MarkupContainer graph = new WebMarkupContainer("graph");\r
                add(graph);\r
@@ -101,7 +100,7 @@ public class LogPanel extends BasePanel {
                                        WicketUtils.newRepositoryParameter(repositoryName)));\r
                }\r
 \r
-               final int hashLen = GitBlit.getInteger(Keys.web.shortCommitIdLength, 6);\r
+               final int hashLen = app().settings().getInteger(Keys.web.shortCommitIdLength, 6);\r
                ListDataProvider<RevCommit> dp = new ListDataProvider<RevCommit>(commits);\r
                DataView<RevCommit> logView = new DataView<RevCommit>("commit", dp) {\r
                        private static final long serialVersionUID = 1L;\r
index ed5780f59851f5f012e128a397a4bcaabcd222dd..1c79760a9dbc461e1e869a022f20228a58b4446c 100644 (file)
@@ -28,7 +28,6 @@ import org.apache.wicket.markup.html.link.Link;
 import org.apache.wicket.markup.html.panel.Fragment;\r
 \r
 import com.gitblit.Constants.AccessRestrictionType;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.SyndicationServlet;\r
 import com.gitblit.models.RepositoryModel;\r
@@ -51,8 +50,8 @@ public class ProjectRepositoryPanel extends BasePanel {
                        final Map<AccessRestrictionType, String> accessRestrictions) {\r
                super(wicketId);\r
 \r
-               final boolean showSwatch = GitBlit.getBoolean(Keys.web.repositoryListSwatches, true);\r
-               final boolean showSize = GitBlit.getBoolean(Keys.web.showRepositorySizes, true);\r
+               final boolean showSwatch = app().settings().getBoolean(Keys.web.repositoryListSwatches, true);\r
+               final boolean showSize = app().settings().getBoolean(Keys.web.showRepositorySizes, true);\r
 \r
                // repository swatch\r
                Component swatch;\r
@@ -110,7 +109,7 @@ public class ProjectRepositoryPanel extends BasePanel {
                } else {\r
                        String owner = "";\r
                        for (String username : entry.owners) {\r
-                               UserModel ownerModel = GitBlit.self().getUserModel(username);\r
+                               UserModel ownerModel = app().users().getUserModel(username);\r
 \r
                                if (ownerModel != null) {\r
                                        owner = ownerModel.getDisplayName();\r
@@ -146,7 +145,7 @@ public class ProjectRepositoryPanel extends BasePanel {
 \r
                                        @Override\r
                                        public void onClick() {\r
-                                               if (GitBlit.self().deleteRepositoryModel(entry)) {\r
+                                               if (app().repositories().deleteRepositoryModel(entry)) {\r
                                                        // redirect to the owning page\r
                                                        if (entry.isPersonalRepository()) {\r
                                                                setResponsePage(getPage().getClass(), WicketUtils.newUsernameParameter(entry.projectPath.substring(1)));\r
index d63f26c3c78ea20e630d82a440f88d2925679f61..abd4ecd39d80a49c4f4cef0c4044904ed7d66baf 100644 (file)
@@ -33,7 +33,6 @@ import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.transport.ReceiveCommand.Type;\r
 \r
 import com.gitblit.Constants;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.RefLogEntry;\r
 import com.gitblit.models.RepositoryCommit;\r
@@ -61,7 +60,7 @@ public class ReflogPanel extends BasePanel {
        public ReflogPanel(String wicketId, final RepositoryModel model, Repository r, int limit, int pageOffset) {\r
                super(wicketId);\r
                boolean pageResults = limit <= 0;\r
-               int changesPerPage = GitBlit.getInteger(Keys.web.reflogChangesPerPage, 10);\r
+               int changesPerPage = app().settings().getInteger(Keys.web.reflogChangesPerPage, 10);\r
                if (changesPerPage <= 1) {\r
                        changesPerPage = 10;\r
                }\r
@@ -111,9 +110,9 @@ public class ReflogPanel extends BasePanel {
        }\r
 \r
        protected void setup(List<RefLogEntry> changes) {\r
-               final int hashLen = GitBlit.getInteger(Keys.web.shortCommitIdLength, 6);\r
+               final int hashLen = app().settings().getInteger(Keys.web.shortCommitIdLength, 6);\r
 \r
-               String dateFormat = GitBlit.getString(Keys.web.datetimestampLongFormat, "EEEE, MMMM d, yyyy HH:mm Z");\r
+               String dateFormat = app().settings().getString(Keys.web.datetimestampLongFormat, "EEEE, MMMM d, yyyy HH:mm Z");\r
                final TimeZone timezone = getTimeZone();\r
                final DateFormat df = new SimpleDateFormat(dateFormat);\r
                df.setTimeZone(timezone);\r
index dd25c48a4ebdf097b4c351f3504b69dc77d2a62a..756b7db4b2f0700d70d3b21a8c2249bd62e0f8ef 100644 (file)
@@ -43,7 +43,6 @@ import org.eclipse.jgit.lib.PersonIdent;
 import com.gitblit.Constants.AccessPermission;
 import com.gitblit.Constants.PermissionType;
 import com.gitblit.Constants.RegistrantType;
-import com.gitblit.GitBlit;
 import com.gitblit.models.RegistrantAccessPermission;
 import com.gitblit.models.UserModel;
 import com.gitblit.utils.DeepCopier;
@@ -140,7 +139,7 @@ public class RegistrantPermissionsPanel extends BasePanel {
                                } else if (RegistrantType.USER.equals(entry.registrantType)) {
                                        // user
                                        PersonIdent ident = new PersonIdent(entry.registrant, "");
-                                       UserModel user = GitBlit.self().getUserModel(entry.registrant);
+                                       UserModel user = app().users().getUserModel(entry.registrant);
                                        if (user != null) {
                                                ident = new PersonIdent(user.getDisplayName(), user.emailAddress == null ? user.getDisplayName() : user.emailAddress);
                                        }
index 9de387a8222028897851c174a51accc94734191f..8de84927245af96dcb75eaab6e575c5e8a1e392b 100644 (file)
@@ -43,7 +43,6 @@ import org.apache.wicket.model.IModel;
 import org.apache.wicket.model.Model;\r
 \r
 import com.gitblit.Constants.AccessRestrictionType;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.SyndicationServlet;\r
 import com.gitblit.models.ProjectModel;\r
@@ -72,7 +71,7 @@ public class RepositoriesPanel extends BasePanel {
                super(wicketId);\r
 \r
                final boolean linksActive = enableLinks;\r
-               final boolean showSize = GitBlit.getBoolean(Keys.web.showRepositorySizes, true);\r
+               final boolean showSize = app().settings().getBoolean(Keys.web.showRepositorySizes, true);\r
 \r
                final UserModel user = GitBlitWebSession.get().getUser();\r
 \r
@@ -88,10 +87,10 @@ public class RepositoriesPanel extends BasePanel {
 \r
                                @Override\r
                                public void onClick() {\r
-                                       GitBlit.self().resetRepositoryListCache();\r
+                                       app().repositories().resetRepositoryListCache();\r
                                        setResponsePage(RepositoriesPage.class);\r
                                }\r
-                       }.setVisible(GitBlit.getBoolean(Keys.git.cacheRepositoryList, true)));\r
+                       }.setVisible(app().settings().getBoolean(Keys.git.cacheRepositoryList, true)));\r
                        managementLinks.add(new BookmarkablePageLink<Void>("newRepository", EditRepositoryPage.class));\r
                        add(managementLinks);\r
                } else if (showManagement && user != null && user.canCreate()) {\r
@@ -104,7 +103,7 @@ public class RepositoriesPanel extends BasePanel {
                        add (new Label("managementPanel").setVisible(false));\r
                }\r
 \r
-               if (GitBlit.getString(Keys.web.repositoryListType, "flat").equalsIgnoreCase("grouped")) {\r
+               if (app().settings().getString(Keys.web.repositoryListType, "flat").equalsIgnoreCase("grouped")) {\r
                        List<RepositoryModel> rootRepositories = new ArrayList<RepositoryModel>();\r
                        Map<String, List<RepositoryModel>> groups = new HashMap<String, List<RepositoryModel>>();\r
                        for (RepositoryModel model : models) {\r
@@ -132,7 +131,7 @@ public class RepositoriesPanel extends BasePanel {
                        List<RepositoryModel> groupedModels = new ArrayList<RepositoryModel>();\r
                        for (String root : roots) {\r
                                List<RepositoryModel> subModels = groups.get(root);\r
-                               ProjectModel project = GitBlit.self().getProjectModel(root);\r
+                               ProjectModel project = app().projects().getProjectModel(root);\r
                                GroupRepositoryModel group = new GroupRepositoryModel(project == null ? root : project.name, subModels.size());\r
                                if (project != null) {\r
                                        group.title = project.title;\r
@@ -148,7 +147,7 @@ public class RepositoriesPanel extends BasePanel {
                }\r
 \r
                final String baseUrl = WicketUtils.getGitblitURL(getRequest());\r
-               final boolean showSwatch = GitBlit.getBoolean(Keys.web.repositoryListSwatches, true);\r
+               final boolean showSwatch = app().settings().getBoolean(Keys.web.repositoryListSwatches, true);\r
 \r
                DataView<RepositoryModel> dataView = new DataView<RepositoryModel>("row", dp) {\r
                        private static final long serialVersionUID = 1L;\r
@@ -174,7 +173,7 @@ public class RepositoriesPanel extends BasePanel {
                                        if (name.startsWith(ModelUtils.getUserRepoPrefix())) {\r
                                                // user page\r
                                                String username = ModelUtils.getUserNameFromRepoPath(name);\r
-                                               UserModel user = GitBlit.self().getUserModel(username);\r
+                                               UserModel user = app().users().getUserModel(username);\r
                                                row.add(new LinkPanel("groupName", null, (user == null ? username : user.getDisplayName()) + " (" + groupRow.count + ")", UserPage.class, WicketUtils.newUsernameParameter(username)));\r
                                                row.add(new Label("groupDescription", getString("gb.personalRepositories")));\r
                                        } else {\r
@@ -294,7 +293,7 @@ public class RepositoriesPanel extends BasePanel {
                                if (!ArrayUtils.isEmpty(entry.owners)) {\r
                                        // display first owner\r
                                        for (String username : entry.owners) {\r
-                                               UserModel ownerModel = GitBlit.self().getUserModel(username);\r
+                                               UserModel ownerModel = app().users().getUserModel(username);\r
                                                if (ownerModel != null) {\r
                                                        owner = ownerModel.getDisplayName();\r
                                                        break;\r
@@ -335,7 +334,7 @@ public class RepositoriesPanel extends BasePanel {
 \r
                                                @Override\r
                                                public void onClick() {\r
-                                                       if (GitBlit.self().deleteRepositoryModel(entry)) {\r
+                                                       if (app().repositories().deleteRepositoryModel(entry)) {\r
                                                                if (dp instanceof SortableRepositoriesProvider) {\r
                                                                        info(MessageFormat.format(getString("gb.repositoryDeleted"), entry));\r
                                                                        ((SortableRepositoriesProvider) dp).remove(entry);\r
index ea8693bbd61baa8c5fa76b2f5f232256fc3e7f9c..2049762bc5fc760018b6c397b40bbe0cd9154a9d 100644 (file)
@@ -36,7 +36,6 @@ import org.apache.wicket.protocol.http.request.WebClientInfo;
 \r
 import com.gitblit.Constants.AccessPermission;\r
 import com.gitblit.Constants.AccessRestrictionType;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.GitClientApplication;\r
 import com.gitblit.models.RepositoryModel;\r
@@ -81,7 +80,7 @@ public class RepositoryUrlPanel extends BasePanel {
 \r
                HttpServletRequest req = ((WebRequest) getRequest()).getHttpServletRequest();\r
 \r
-               List<RepositoryUrl> repositoryUrls = GitBlit.self().getRepositoryUrls(req, user, repository);\r
+               List<RepositoryUrl> repositoryUrls = app().gitblit().getRepositoryUrls(req, user, repository);\r
                // grab primary url from the top of the list\r
                primaryUrl = repositoryUrls.size() == 0 ? null : repositoryUrls.get(0);\r
 \r
@@ -104,7 +103,7 @@ public class RepositoryUrlPanel extends BasePanel {
                        add(createRepositoryIndicators(repository));\r
                }\r
 \r
-               boolean allowAppLinks = GitBlit.getBoolean(Keys.web.allowAppCloneLinks, true);\r
+               boolean allowAppLinks = app().settings().getBoolean(Keys.web.allowAppCloneLinks, true);\r
                if (onlyUrls || !canClone || !allowAppLinks) {\r
                        // only display the url(s)\r
                        add(new Label("applicationMenusPanel").setVisible(false));\r
@@ -163,7 +162,7 @@ public class RepositoryUrlPanel extends BasePanel {
                }\r
 \r
                // access restriction icon and tooltip\r
-               if (GitBlit.isServingRepositories()) {\r
+               if (app().runtime().isServingRepositories()) {\r
                        switch (repository.accessRestriction) {\r
                        case NONE:\r
                                urlPanel.add(WicketUtils.newClearPixel("accessRestrictionIcon").setVisible(false));\r
@@ -213,7 +212,7 @@ public class RepositoryUrlPanel extends BasePanel {
                final String userAgent = ((WebClientInfo) GitBlitWebSession.get().getClientInfo()).getUserAgent();\r
 \r
                if (user.canClone(repository)) {\r
-                       for (GitClientApplication app : GitBlit.self().getClientApplications()) {\r
+                       for (GitClientApplication app : app().gitblit().getClientApplications()) {\r
                                if (app.isActive && app.allowsPlatform(userAgent)) {\r
                                        displayedApps.add(app);\r
                                }\r
@@ -345,7 +344,7 @@ public class RepositoryUrlPanel extends BasePanel {
        }\r
 \r
        protected Fragment createCopyFragment(String text) {\r
-               if (GitBlit.getBoolean(Keys.web.allowFlashCopyToClipboard, true)) {\r
+               if (app().settings().getBoolean(Keys.web.allowFlashCopyToClipboard, true)) {\r
                        // clippy: flash-based copy & paste\r
                        Fragment copyFragment = new Fragment("copyFunction", "clippyPanel", this);\r
                        String baseUrl = WicketUtils.getGitblitURL(getRequest());\r
@@ -450,12 +449,12 @@ public class RepositoryUrlPanel extends BasePanel {
                        fragment.add(wc);\r
                }\r
 \r
-               boolean allowForking = GitBlit.getBoolean(Keys.web.allowForking, true);\r
+               boolean allowForking = app().settings().getBoolean(Keys.web.allowForking, true);\r
                if (!allowForking || user == null || !user.isAuthenticated) {\r
                        // must be logged-in to fork, hide all fork controls\r
                        fragment.add(new Label("forksProhibitedIndicator").setVisible(false));\r
                } else {\r
-                       String fork = GitBlit.self().getFork(user.username, repository.name);\r
+                       String fork = app().repositories().getFork(user.username, repository.name);\r
                        boolean hasFork = fork != null;\r
                        boolean canFork = user.canFork(repository);\r
 \r
index bfa38ed457ccf73df2c236c2635ed957127fae4c..a60cc9305f56429901ef75cebf3eb43befd6d920 100644 (file)
@@ -29,7 +29,6 @@ import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.revwalk.RevCommit;\r
 \r
 import com.gitblit.Constants;\r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.RefModel;\r
 import com.gitblit.utils.JGitUtils;\r
@@ -51,7 +50,7 @@ public class SearchPanel extends BasePanel {
                        boolean showRemoteRefs) {\r
                super(wicketId);\r
                boolean pageResults = limit <= 0;\r
-               int itemsPerPage = GitBlit.getInteger(Keys.web.itemsPerPage, 50);\r
+               int itemsPerPage = app().settings().getInteger(Keys.web.itemsPerPage, 50);\r
                if (itemsPerPage <= 1) {\r
                        itemsPerPage = 50;\r
                }\r
index f567c78b073ec0e7ca058de630a29b90f2fa14ca..79ddd02d9c41bf6675583263ca29ae95f9dd8c4f 100644 (file)
@@ -26,7 +26,6 @@ import org.apache.wicket.markup.repeater.Item;
 import org.apache.wicket.markup.repeater.data.DataView;\r
 import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.models.TeamModel;\r
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.pages.EditTeamPage;\r
@@ -40,9 +39,9 @@ public class TeamsPanel extends BasePanel {
 \r
                Fragment adminLinks = new Fragment("adminPanel", "adminLinks", this);\r
                adminLinks.add(new BookmarkablePageLink<Void>("newTeam", EditTeamPage.class));\r
-               add(adminLinks.setVisible(showAdmin && GitBlit.self().supportsTeamMembershipChanges(null)));\r
+               add(adminLinks.setVisible(showAdmin && app().users().supportsTeamMembershipChanges(null)));\r
 \r
-               final List<TeamModel> teams = GitBlit.self().getAllTeams();\r
+               final List<TeamModel> teams = app().users().getAllTeams();\r
                DataView<TeamModel> teamsView = new DataView<TeamModel>("teamRow",\r
                                new ListDataProvider<TeamModel>(teams)) {\r
                        private static final long serialVersionUID = 1L;\r
@@ -74,7 +73,7 @@ public class TeamsPanel extends BasePanel {
 \r
                                        @Override\r
                                        public void onClick() {\r
-                                               if (GitBlit.self().deleteTeam(entry.name)) {\r
+                                               if (app().users().deleteTeam(entry.name)) {\r
                                                        teams.remove(entry);\r
                                                        info(MessageFormat.format("Team ''{0}'' deleted.", entry.name));\r
                                                } else {\r
index 545734f05cc407fdd10c37684feb81c917ad63e4..9c1667ff5603a3587485035a83f242e1316ce2fe 100644 (file)
@@ -26,7 +26,6 @@ import org.apache.wicket.markup.repeater.Item;
 import org.apache.wicket.markup.repeater.data.DataView;\r
 import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.models.UserModel;\r
 import com.gitblit.utils.StringUtils;\r
 import com.gitblit.wicket.WicketUtils;\r
@@ -41,10 +40,10 @@ public class UsersPanel extends BasePanel {
 \r
                Fragment adminLinks = new Fragment("adminPanel", "adminLinks", this);\r
                adminLinks.add(new BookmarkablePageLink<Void>("newUser", EditUserPage.class)\r
-                               .setVisible(GitBlit.self().supportsAddUser()));\r
+                               .setVisible(app().users().supportsAddUser()));\r
                add(adminLinks.setVisible(showAdmin));\r
 \r
-               final List<UserModel> users = GitBlit.self().getAllUsers();\r
+               final List<UserModel> users = app().users().getAllUsers();\r
                DataView<UserModel> usersView = new DataView<UserModel>("userRow",\r
                                new ListDataProvider<UserModel>(users)) {\r
                        private static final long serialVersionUID = 1L;\r
@@ -95,7 +94,7 @@ public class UsersPanel extends BasePanel {
 \r
                                        @Override\r
                                        public void onClick() {\r
-                                               if (GitBlit.self().deleteUser(entry.username)) {\r
+                                               if (app().users().deleteUser(entry.username)) {\r
                                                        users.remove(entry);\r
                                                        info(MessageFormat.format(getString("gb.userDeleted"), entry.username));\r
                                                } else {\r