summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/wicket/pages
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2013-11-16 11:42:06 -0500
committerJames Moger <james.moger@gitblit.com>2013-11-26 16:07:04 -0500
commit99d0d4fd66f3490b61c700065b7d16bc4e73f226 (patch)
tree0e5d8bd9e7b14905ab6ea71e8bf6253345415a70 /src/main/java/com/gitblit/wicket/pages
parenta7a0b8ea01dca14602fdb49047d987c36461e861 (diff)
downloadgitblit-99d0d4fd66f3490b61c700065b7d16bc4e73f226.tar.gz
gitblit-99d0d4fd66f3490b61c700065b7d16bc4e73f226.zip
Eliminate nearly all direct GitBlit singleton references in Wicket
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
Diffstat (limited to 'src/main/java/com/gitblit/wicket/pages')
-rw-r--r--src/main/java/com/gitblit/wicket/pages/ActivityPage.java7
-rw-r--r--src/main/java/com/gitblit/wicket/pages/BasePage.java39
-rw-r--r--src/main/java/com/gitblit/wicket/pages/BlamePage.java3
-rw-r--r--src/main/java/com/gitblit/wicket/pages/BlobPage.java11
-rw-r--r--src/main/java/com/gitblit/wicket/pages/ChangePasswordPage.java19
-rw-r--r--src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java3
-rw-r--r--src/main/java/com/gitblit/wicket/pages/CommitPage.java3
-rw-r--r--src/main/java/com/gitblit/wicket/pages/DashboardPage.java7
-rw-r--r--src/main/java/com/gitblit/wicket/pages/DocPage.java5
-rw-r--r--src/main/java/com/gitblit/wicket/pages/DocsPage.java3
-rw-r--r--src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java53
-rw-r--r--src/main/java/com/gitblit/wicket/pages/EditTeamPage.java25
-rw-r--r--src/main/java/com/gitblit/wicket/pages/EditUserPage.java33
-rw-r--r--src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java5
-rw-r--r--src/main/java/com/gitblit/wicket/pages/FederationPage.java5
-rw-r--r--src/main/java/com/gitblit/wicket/pages/FederationRegistrationPage.java3
-rw-r--r--src/main/java/com/gitblit/wicket/pages/ForkPage.java12
-rw-r--r--src/main/java/com/gitblit/wicket/pages/ForksPage.java7
-rw-r--r--src/main/java/com/gitblit/wicket/pages/LogoutPage.java5
-rw-r--r--src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java9
-rw-r--r--src/main/java/com/gitblit/wicket/pages/MyDashboardPage.java15
-rw-r--r--src/main/java/com/gitblit/wicket/pages/OverviewPage.java13
-rw-r--r--src/main/java/com/gitblit/wicket/pages/PatchPage.java6
-rw-r--r--src/main/java/com/gitblit/wicket/pages/ProjectPage.java7
-rw-r--r--src/main/java/com/gitblit/wicket/pages/ProjectsPage.java5
-rw-r--r--src/main/java/com/gitblit/wicket/pages/RawPage.java11
-rw-r--r--src/main/java/com/gitblit/wicket/pages/RepositoriesPage.java9
-rw-r--r--src/main/java/com/gitblit/wicket/pages/RepositoryPage.java48
-rw-r--r--src/main/java/com/gitblit/wicket/pages/ReviewProposalPage.java16
-rw-r--r--src/main/java/com/gitblit/wicket/pages/RootPage.java55
-rw-r--r--src/main/java/com/gitblit/wicket/pages/RootSubPage.java5
-rw-r--r--src/main/java/com/gitblit/wicket/pages/SendProposalPage.java5
-rw-r--r--src/main/java/com/gitblit/wicket/pages/SessionPage.java17
-rw-r--r--src/main/java/com/gitblit/wicket/pages/SummaryPage.java17
-rw-r--r--src/main/java/com/gitblit/wicket/pages/UserPage.java9
35 files changed, 234 insertions, 261 deletions
diff --git a/src/main/java/com/gitblit/wicket/pages/ActivityPage.java b/src/main/java/com/gitblit/wicket/pages/ActivityPage.java
index 99992eae..5e7332f5 100644
--- a/src/main/java/com/gitblit/wicket/pages/ActivityPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/ActivityPage.java
@@ -29,7 +29,6 @@ import org.apache.wicket.behavior.HeaderContributor;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Fragment;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.Activity;
import com.gitblit.models.Metric;
@@ -66,7 +65,7 @@ public class ActivityPage extends RootPage {
// parameters
int daysBack = WicketUtils.getDaysBack(params);
if (daysBack < 1) {
- daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);
+ daysBack = app().settings().getInteger(Keys.web.activityDuration, 7);
}
String objectId = WicketUtils.getObject(params);
@@ -113,7 +112,7 @@ public class ActivityPage extends RootPage {
daysBack, totalCommits, totalAuthors)));
// create the activity charts
- if (GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {
+ if (app().settings().getBoolean(Keys.web.generateActivityGraph, true)) {
GoogleCharts charts = createCharts(recentActivity);
add(new HeaderContributor(charts));
add(new Fragment("chartsPanel", "chartsFragment", this));
@@ -137,7 +136,7 @@ public class ActivityPage extends RootPage {
ActivityPage.class);
PageParameters currentParameters = getPageParameters();
- int daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);
+ int daysBack = app().settings().getInteger(Keys.web.activityDuration, 7);
if (currentParameters != null && !currentParameters.containsKey("db")) {
currentParameters.put("db", daysBack);
}
diff --git a/src/main/java/com/gitblit/wicket/pages/BasePage.java b/src/main/java/com/gitblit/wicket/pages/BasePage.java
index 9bae3783..647a9388 100644
--- a/src/main/java/com/gitblit/wicket/pages/BasePage.java
+++ b/src/main/java/com/gitblit/wicket/pages/BasePage.java
@@ -52,7 +52,6 @@ import com.gitblit.Constants.AccessPermission;
import com.gitblit.Constants.AccessRestrictionType;
import com.gitblit.Constants.AuthorizationControl;
import com.gitblit.Constants.FederationStrategy;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.ProjectModel;
import com.gitblit.models.TeamModel;
@@ -83,7 +82,7 @@ public abstract class BasePage extends SessionPage {
}
private void customizeHeader() {
- if (GitBlit.getBoolean(Keys.web.useResponsiveLayout, true)) {
+ if (app().settings().getBoolean(Keys.web.useResponsiveLayout, true)) {
add(CSSPackageResource.getHeaderContribution("bootstrap/css/bootstrap-responsive.css"));
}
}
@@ -121,7 +120,7 @@ public abstract class BasePage extends SessionPage {
@Override
protected void onBeforeRender() {
- if (GitBlit.isDebugMode()) {
+ if (app().isDebugMode()) {
// strip Wicket tags in debug mode for jQuery DOM traversal
Application.get().getMarkupSettings().setStripWicketTags(true);
}
@@ -130,7 +129,7 @@ public abstract class BasePage extends SessionPage {
@Override
protected void onAfterRender() {
- if (GitBlit.isDebugMode()) {
+ if (app().isDebugMode()) {
// restore Wicket debug tags
Application.get().getMarkupSettings().setStripWicketTags(false);
}
@@ -141,8 +140,8 @@ public abstract class BasePage extends SessionPage {
protected void setHeaders(WebResponse response) {
// set canonical link as http header for SEO (issue-304)
// https://support.google.com/webmasters/answer/139394?hl=en
- response.setHeader("Link" ,MessageFormat.format("<{0}>; rel=\"canonical\"", getCanonicalUrl()));
- int expires = GitBlit.getInteger(Keys.web.pageCacheExpires, 0);
+ response.setHeader("Link", MessageFormat.format("<{0}>; rel=\"canonical\"", getCanonicalUrl()));
+ int expires = app().settings().getInteger(Keys.web.pageCacheExpires, 0);
if (expires > 0) {
// pages are personalized for the authenticated user so they must be
// marked private to prohibit proxy servers from caching them
@@ -164,10 +163,10 @@ public abstract class BasePage extends SessionPage {
CacheControl cacheControl = getClass().getAnnotation(CacheControl.class);
switch (cacheControl.value()) {
case ACTIVITY:
- setLastModified(GitBlit.getLastActivityDate());
+ setLastModified(app().getLastActivityDate());
break;
case BOOT:
- setLastModified(GitBlit.getBootDate());
+ setLastModified(app().getBootDate());
break;
case NONE:
break;
@@ -188,21 +187,21 @@ public abstract class BasePage extends SessionPage {
return;
}
- if (when.before(GitBlit.getBootDate())) {
+ if (when.before(app().getBootDate())) {
// last-modified can not be before the Gitblit boot date
// this helps ensure that pages are properly refreshed after a
// server config change
- when = GitBlit.getBootDate();
+ when = app().getBootDate();
}
- int expires = GitBlit.getInteger(Keys.web.pageCacheExpires, 0);
+ int expires = app().settings().getInteger(Keys.web.pageCacheExpires, 0);
WebResponse response = (WebResponse) getResponse();
response.setLastModifiedTime(Time.valueOf(when));
response.setDateHeader("Expires", System.currentTimeMillis() + Duration.minutes(expires).getMilliseconds());
}
protected void setupPage(String repositoryName, String pageName) {
- String siteName = GitBlit.getString(Keys.web.siteName, Constants.NAME);
+ String siteName = app().settings().getString(Keys.web.siteName, Constants.NAME);
if (StringUtils.isEmpty(siteName)) {
siteName = Constants.NAME;
}
@@ -212,16 +211,16 @@ public abstract class BasePage extends SessionPage {
add(new Label("title", siteName));
}
- String rootLinkUrl = GitBlit.getString(Keys.web.rootLink, urlFor(GitBlitWebApp.get().getHomePage(), null).toString());
+ String rootLinkUrl = app().settings().getString(Keys.web.rootLink, urlFor(GitBlitWebApp.get().getHomePage(), null).toString());
ExternalLink rootLink = new ExternalLink("rootLink", rootLinkUrl);
- WicketUtils.setHtmlTooltip(rootLink, GitBlit.getString(Keys.web.siteName, Constants.NAME));
+ WicketUtils.setHtmlTooltip(rootLink, app().settings().getString(Keys.web.siteName, Constants.NAME));
add(rootLink);
// Feedback panel for info, warning, and non-fatal error messages
add(new FeedbackPanel("feedback"));
add(new Label("gbVersion", "v" + Constants.getVersion()));
- if (GitBlit.getBoolean(Keys.web.aggressiveHeapManagement, false)) {
+ if (app().settings().getBoolean(Keys.web.aggressiveHeapManagement, false)) {
System.gc();
}
}
@@ -314,8 +313,8 @@ public abstract class BasePage extends SessionPage {
}
protected TimeZone getTimeZone() {
- return GitBlit.getBoolean(Keys.web.useClientTimezone, false) ? GitBlitWebSession.get()
- .getTimezone() : GitBlit.getTimezone();
+ return app().settings().getBoolean(Keys.web.useClientTimezone, false) ? GitBlitWebSession.get()
+ .getTimezone() : app().getTimezone();
}
protected String getServerName() {
@@ -326,7 +325,7 @@ public abstract class BasePage extends SessionPage {
protected List<ProjectModel> getProjectModels() {
final UserModel user = GitBlitWebSession.get().getUser();
- List<ProjectModel> projects = GitBlit.self().getProjectModels(user, true);
+ List<ProjectModel> projects = app().projects().getProjectModels(user, true);
return projects;
}
@@ -339,7 +338,7 @@ public abstract class BasePage extends SessionPage {
String regex = WicketUtils.getRegEx(params);
String team = WicketUtils.getTeam(params);
int daysBack = params.getInt("db", 0);
- int maxDaysBack = GitBlit.getInteger(Keys.web.activityDurationMaximum, 30);
+ int maxDaysBack = app().settings().getInteger(Keys.web.activityDurationMaximum, 30);
List<ProjectModel> availableModels = getProjectModels();
Set<ProjectModel> models = new HashSet<ProjectModel>();
@@ -363,7 +362,7 @@ public abstract class BasePage extends SessionPage {
// need TeamModels first
List<TeamModel> teamModels = new ArrayList<TeamModel>();
for (String name : teams) {
- TeamModel teamModel = GitBlit.self().getTeamModel(name);
+ TeamModel teamModel = app().users().getTeamModel(name);
if (teamModel != null) {
teamModels.add(teamModel);
}
diff --git a/src/main/java/com/gitblit/wicket/pages/BlamePage.java b/src/main/java/com/gitblit/wicket/pages/BlamePage.java
index 9f00d212..52682639 100644
--- a/src/main/java/com/gitblit/wicket/pages/BlamePage.java
+++ b/src/main/java/com/gitblit/wicket/pages/BlamePage.java
@@ -30,7 +30,6 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.AnnotatedLine;
import com.gitblit.models.PathModel;
@@ -71,7 +70,7 @@ public class BlamePage extends RepositoryPage {
add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, blobPath, objectId));
- String format = GitBlit.getString(Keys.web.datetimestampLongFormat,
+ String format = app().settings().getString(Keys.web.datetimestampLongFormat,
"EEEE, MMMM d, yyyy HH:mm Z");
final DateFormat df = new SimpleDateFormat(format);
df.setTimeZone(getTimeZone());
diff --git a/src/main/java/com/gitblit/wicket/pages/BlobPage.java b/src/main/java/com/gitblit/wicket/pages/BlobPage.java
index 56ad5b96..c4eca10a 100644
--- a/src/main/java/com/gitblit/wicket/pages/BlobPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/BlobPage.java
@@ -28,7 +28,6 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.StringUtils;
@@ -50,7 +49,7 @@ public class BlobPage extends RepositoryPage {
Repository r = getRepository();
final String blobPath = WicketUtils.getPath(params);
- String [] encodings = GitBlit.getEncodings();
+ String [] encodings = getEncodings();
if (StringUtils.isEmpty(blobPath)) {
// blob by objectid
@@ -75,7 +74,7 @@ public class BlobPage extends RepositoryPage {
}
// see if we should redirect to the doc page
- MarkupProcessor processor = new MarkupProcessor(GitBlit.getSettings());
+ MarkupProcessor processor = new MarkupProcessor(app().settings());
for (String ext : processor.getMarkupExtensions()) {
if (ext.equals(extension)) {
setResponsePage(DocPage.class, params);
@@ -102,13 +101,13 @@ public class BlobPage extends RepositoryPage {
// Map the extensions to types
Map<String, Integer> map = new HashMap<String, Integer>();
- for (String ext : GitBlit.getStrings(Keys.web.prettyPrintExtensions)) {
+ for (String ext : app().settings().getStrings(Keys.web.prettyPrintExtensions)) {
map.put(ext.toLowerCase(), 1);
}
- for (String ext : GitBlit.getStrings(Keys.web.imageExtensions)) {
+ for (String ext : app().settings().getStrings(Keys.web.imageExtensions)) {
map.put(ext.toLowerCase(), 2);
}
- for (String ext : GitBlit.getStrings(Keys.web.binaryExtensions)) {
+ for (String ext : app().settings().getStrings(Keys.web.binaryExtensions)) {
map.put(ext.toLowerCase(), 3);
}
diff --git a/src/main/java/com/gitblit/wicket/pages/ChangePasswordPage.java b/src/main/java/com/gitblit/wicket/pages/ChangePasswordPage.java
index 302de0da..3e308f1b 100644
--- a/src/main/java/com/gitblit/wicket/pages/ChangePasswordPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/ChangePasswordPage.java
@@ -25,7 +25,6 @@ import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.protocol.http.WebResponse;
-import com.gitblit.GitBlit;
import com.gitblit.GitBlitException;
import com.gitblit.Keys;
import com.gitblit.models.UserModel;
@@ -45,16 +44,16 @@ public class ChangePasswordPage extends RootSubPage {
throw new RestartResponseException(getApplication().getHomePage());
}
- if (!GitBlit.getBoolean(Keys.web.authenticateAdminPages, true)
- && !GitBlit.getBoolean(Keys.web.authenticateViewPages, false)) {
+ if (!app().settings().getBoolean(Keys.web.authenticateAdminPages, true)
+ && !app().settings().getBoolean(Keys.web.authenticateViewPages, false)) {
// no authentication enabled
throw new RestartResponseException(getApplication().getHomePage());
}
UserModel user = GitBlitWebSession.get().getUser();
- if (!GitBlit.self().supportsCredentialChanges(user)) {
+ if (!app().users().supportsCredentialChanges(user)) {
error(MessageFormat.format(getString("gb.userServiceDoesNotPermitPasswordChanges"),
- GitBlit.getString(Keys.realm.userService, "${baseFolder}/users.conf")), true);
+ app().settings().getString(Keys.realm.userService, "${baseFolder}/users.conf")), true);
}
setupPage(getString("gb.changePassword"), user.username);
@@ -74,7 +73,7 @@ public class ChangePasswordPage extends RootSubPage {
}
// ensure password satisfies minimum length requirement
- int minLength = GitBlit.getInteger(Keys.realm.minPasswordLength, 5);
+ int minLength = app().settings().getInteger(Keys.realm.minPasswordLength, 5);
if (minLength < 4) {
minLength = 4;
}
@@ -86,7 +85,7 @@ public class ChangePasswordPage extends RootSubPage {
UserModel user = GitBlitWebSession.get().getUser();
// convert to MD5 digest, if appropriate
- String type = GitBlit.getString(Keys.realm.passwordStorage, "md5");
+ String type = app().settings().getString(Keys.realm.passwordStorage, "md5");
if (type.equalsIgnoreCase("md5")) {
// store MD5 digest of password
password = StringUtils.MD5_TYPE + StringUtils.getMD5(password);
@@ -98,10 +97,10 @@ public class ChangePasswordPage extends RootSubPage {
user.password = password;
try {
- GitBlit.self().updateUserModel(user.username, user, false);
- if (GitBlit.getBoolean(Keys.web.allowCookieAuthentication, false)) {
+ app().users().updateUserModel(user.username, user, false);
+ if (app().settings().getBoolean(Keys.web.allowCookieAuthentication, false)) {
WebResponse response = (WebResponse) getRequestCycle().getResponse();
- GitBlit.self().setCookie(response, user);
+ app().session().setCookie(response, user);
}
} catch (GitBlitException e) {
error(e.getMessage());
diff --git a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java
index 468fb667..5d14bfec 100644
--- a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java
@@ -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));
}
};
diff --git a/src/main/java/com/gitblit/wicket/pages/CommitPage.java b/src/main/java/com/gitblit/wicket/pages/CommitPage.java
index 1772f3af..59422332 100644
--- a/src/main/java/com/gitblit/wicket/pages/CommitPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/CommitPage.java
@@ -32,7 +32,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;
@@ -136,7 +135,7 @@ public class CommitPage 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));
}
};
diff --git a/src/main/java/com/gitblit/wicket/pages/DashboardPage.java b/src/main/java/com/gitblit/wicket/pages/DashboardPage.java
index 46adcffe..959a3d31 100644
--- a/src/main/java/com/gitblit/wicket/pages/DashboardPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/DashboardPage.java
@@ -34,7 +34,6 @@ import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Fragment;
import org.eclipse.jgit.lib.Repository;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.DailyLogEntry;
import com.gitblit.models.Metric;
@@ -83,7 +82,7 @@ public abstract class DashboardPage extends RootPage {
continue;
}
if (model.hasCommits && model.lastChange.after(minimumDate)) {
- Repository repository = GitBlit.self().getRepository(model.name);
+ Repository repository = app().repositories().getRepository(model.name);
List<DailyLogEntry> entries = RefLogUtils.getDailyLogByRef(model.name, repository, minimumDate, timezone);
digests.addAll(entries);
repository.close();
@@ -123,7 +122,7 @@ public abstract class DashboardPage extends RootPage {
if (!ArrayUtils.isEmpty(digests)) {
// aggregate author exclusions
Set<String> authorExclusions = new TreeSet<String>();
- for (String author : GitBlit.getStrings(Keys.web.metricAuthorExclusions)) {
+ for (String author : app().settings().getStrings(Keys.web.metricAuthorExclusions)) {
authorExclusions.add(author.toLowerCase());
}
for (RepositoryModel model : repositories) {
@@ -217,7 +216,7 @@ public abstract class DashboardPage extends RootPage {
frag.add(new Label("feedheader", MessageFormat.format(headerPattern,
daysBack, totalCommits, authorMetrics.size())));
- if (GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {
+ if (app().settings().getBoolean(Keys.web.generateActivityGraph, true)) {
// build google charts
GoogleCharts charts = new GoogleCharts();
diff --git a/src/main/java/com/gitblit/wicket/pages/DocPage.java b/src/main/java/com/gitblit/wicket/pages/DocPage.java
index ab0c4623..03d23372 100644
--- a/src/main/java/com/gitblit/wicket/pages/DocPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/DocPage.java
@@ -24,7 +24,6 @@ import org.apache.wicket.markup.html.panel.Fragment;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
-import com.gitblit.GitBlit;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.CacheControl;
@@ -41,11 +40,11 @@ public class DocPage extends RepositoryPage {
super(params);
final String path = WicketUtils.getPath(params).replace("%2f", "/").replace("%2F", "/");
- MarkupProcessor processor = new MarkupProcessor(GitBlit.getSettings());
+ MarkupProcessor processor = new MarkupProcessor(app().settings());
Repository r = getRepository();
RevCommit commit = JGitUtils.getCommit(r, objectId);
- String [] encodings = GitBlit.getEncodings();
+ String [] encodings = getEncodings();
// Read raw markup content and transform it to html
String documentPath = path;
diff --git a/src/main/java/com/gitblit/wicket/pages/DocsPage.java b/src/main/java/com/gitblit/wicket/pages/DocsPage.java
index 174311c4..3f9ccdb5 100644
--- a/src/main/java/com/gitblit/wicket/pages/DocsPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/DocsPage.java
@@ -30,7 +30,6 @@ import org.apache.wicket.markup.repeater.data.ListDataProvider;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
-import com.gitblit.GitBlit;
import com.gitblit.models.PathModel;
import com.gitblit.utils.ByteFormat;
import com.gitblit.utils.JGitUtils;
@@ -49,7 +48,7 @@ public class DocsPage extends RepositoryPage {
public DocsPage(PageParameters params) {
super(params);
- MarkupProcessor processor = new MarkupProcessor(GitBlit.getSettings());
+ MarkupProcessor processor = new MarkupProcessor(app().settings());
Repository r = getRepository();
RevCommit head = JGitUtils.getCommit(r, null);
diff --git a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java
index 1b3cbd6c..76b34f3a 100644
--- a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java
@@ -55,7 +55,6 @@ import com.gitblit.Constants.AuthorizationControl;
import com.gitblit.Constants.CommitMessageRenderer;
import com.gitblit.Constants.FederationStrategy;
import com.gitblit.Constants.RegistrantType;
-import com.gitblit.GitBlit;
import com.gitblit.GitBlitException;
import com.gitblit.Keys;
import com.gitblit.models.RegistrantAccessPermission;
@@ -86,9 +85,9 @@ public class EditRepositoryPage extends RootSubPage {
super();
isCreate = true;
RepositoryModel model = new RepositoryModel();
- String restriction = GitBlit.getString(Keys.git.defaultAccessRestriction, "PUSH");
+ String restriction = app().settings().getString(Keys.git.defaultAccessRestriction, "PUSH");
model.accessRestriction = AccessRestrictionType.fromName(restriction);
- String authorization = GitBlit.getString(Keys.git.defaultAuthorizationControl, null);
+ String authorization = app().settings().getString(Keys.git.defaultAuthorizationControl, null);
model.authorizationControl = AuthorizationControl.fromName(authorization);
GitBlitWebSession session = GitBlitWebSession.get();
@@ -113,7 +112,7 @@ public class EditRepositoryPage extends RootSubPage {
super(params);
isCreate = false;
String name = WicketUtils.getRepositoryName(params);
- RepositoryModel model = GitBlit.self().getRepositoryModel(name);
+ RepositoryModel model = app().repositories().getRepositoryModel(name);
setupPage(model);
setStatelessHint(false);
setOutputMarkupId(true);
@@ -154,8 +153,8 @@ public class EditRepositoryPage extends RootSubPage {
}
} else {
super.setupPage(getString("gb.edit"), repositoryModel.name);
- repositoryUsers.addAll(GitBlit.self().getUserAccessPermissions(repositoryModel));
- repositoryTeams.addAll(GitBlit.self().getTeamAccessPermissions(repositoryModel));
+ repositoryUsers.addAll(app().repositories().getUserAccessPermissions(repositoryModel));
+ repositoryTeams.addAll(app().repositories().getTeamAccessPermissions(repositoryModel));
Collections.sort(repositoryUsers);
Collections.sort(repositoryTeams);
@@ -168,13 +167,13 @@ public class EditRepositoryPage extends RootSubPage {
final String oldName = repositoryModel.name;
final RegistrantPermissionsPanel usersPalette = new RegistrantPermissionsPanel("users",
- RegistrantType.USER, GitBlit.self().getAllUsernames(), repositoryUsers, getAccessPermissions());
+ RegistrantType.USER, app().users().getAllUsernames(), repositoryUsers, getAccessPermissions());
final RegistrantPermissionsPanel teamsPalette = new RegistrantPermissionsPanel("teams",
- RegistrantType.TEAM, GitBlit.self().getAllTeamnames(), repositoryTeams, getAccessPermissions());
+ RegistrantType.TEAM, app().users().getAllTeamnames(), repositoryTeams, getAccessPermissions());
// owners palette
List<String> owners = new ArrayList<String>(repositoryModel.owners);
- List<String> persons = GitBlit.self().getAllUsernames();
+ List<String> persons = app().users().getAllUsernames();
final Palette<String> ownersPalette = new Palette<String>("owners", new ListModel<String>(owners), new CollectionModel<String>(
persons), new StringChoiceRenderer(), 12, true);
@@ -182,14 +181,14 @@ public class EditRepositoryPage extends RootSubPage {
List<String> allLocalBranches = new ArrayList<String>();
allLocalBranches.add(Constants.DEFAULT_BRANCH);
allLocalBranches.addAll(repositoryModel.getLocalBranches());
- boolean luceneEnabled = GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true);
+ boolean luceneEnabled = app().settings().getBoolean(Keys.web.allowLuceneIndexing, true);
final Palette<String> indexedBranchesPalette = new Palette<String>("indexedBranches", new ListModel<String>(
indexedBranches), new CollectionModel<String>(allLocalBranches),
new StringChoiceRenderer(), 8, false);
indexedBranchesPalette.setEnabled(luceneEnabled);
// federation sets palette
- List<String> sets = GitBlit.getStrings(Keys.federation.sets);
+ List<String> sets = app().settings().getStrings(Keys.federation.sets);
final Palette<String> federationSetsPalette = new Palette<String>("federationSets",
new ListModel<String>(federationSets), new CollectionModel<String>(sets),
new StringChoiceRenderer(), 8, false);
@@ -199,8 +198,8 @@ public class EditRepositoryPage extends RootSubPage {
preReceiveScripts.addAll(repositoryModel.preReceiveScripts);
}
final Palette<String> preReceivePalette = new Palette<String>("preReceiveScripts",
- new ListModel<String>(preReceiveScripts), new CollectionModel<String>(GitBlit
- .self().getPreReceiveScriptsUnused(repositoryModel)),
+ new ListModel<String>(preReceiveScripts), new CollectionModel<String>(app().repositories()
+ .getPreReceiveScriptsUnused(repositoryModel)),
new StringChoiceRenderer(), 12, true);
// post-receive palette
@@ -208,12 +207,12 @@ public class EditRepositoryPage extends RootSubPage {
postReceiveScripts.addAll(repositoryModel.postReceiveScripts);
}
final Palette<String> postReceivePalette = new Palette<String>("postReceiveScripts",
- new ListModel<String>(postReceiveScripts), new CollectionModel<String>(GitBlit
- .self().getPostReceiveScriptsUnused(repositoryModel)),
+ new ListModel<String>(postReceiveScripts), new CollectionModel<String>(app().repositories()
+ .getPostReceiveScriptsUnused(repositoryModel)),
new StringChoiceRenderer(), 12, true);
// custom fields
- final Map<String, String> customFieldsMap = GitBlit.getMap(Keys.groovy.customFields);
+ final Map<String, String> customFieldsMap = app().settings().getMap(Keys.groovy.customFields);
List<String> customKeys = new ArrayList<String>(customFieldsMap.keySet());
final ListView<String> customFieldsListView = new ListView<String>("customFieldsListView", customKeys) {
@@ -393,12 +392,12 @@ public class EditRepositoryPage extends RootSubPage {
}
// save the repository
- GitBlit.self().updateRepositoryModel(oldName, repositoryModel, isCreate);
+ app().repositories().updateRepositoryModel(oldName, repositoryModel, isCreate);
// repository access permissions
if (repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE)) {
- GitBlit.self().setUserAccessPermissions(repositoryModel, repositoryUsers);
- GitBlit.self().setTeamAccessPermissions(repositoryModel, repositoryTeams);
+ app().repositories().setUserAccessPermissions(repositoryModel, repositoryUsers);
+ app().repositories().setTeamAccessPermissions(repositoryModel, repositoryTeams);
}
} catch (GitBlitException e) {
error(e.getMessage());
@@ -416,9 +415,9 @@ public class EditRepositoryPage extends RootSubPage {
form.add(new TextField<String>("name").setEnabled(allowEditName));
form.add(new TextField<String>("description"));
form.add(ownersPalette);
- form.add(new CheckBox("allowForks").setEnabled(GitBlit.getBoolean(Keys.web.allowForking, true)));
+ form.add(new CheckBox("allowForks").setEnabled(app().settings().getBoolean(Keys.web.allowForking, true)));
DropDownChoice<AccessRestrictionType> accessRestriction = new DropDownChoice<AccessRestrictionType>("accessRestriction",
- AccessRestrictionType.choices(GitBlit.getBoolean(Keys.git.allowAnonymousPushes, false)), new AccessRestrictionRenderer());
+ AccessRestrictionType.choices(app().settings().getBoolean(Keys.git.allowAnonymousPushes, false)), new AccessRestrictionRenderer());
form.add(accessRestriction);
form.add(new CheckBox("isFrozen"));
// TODO enable origin definition
@@ -431,7 +430,7 @@ public class EditRepositoryPage extends RootSubPage {
}
form.add(new DropDownChoice<String>("HEAD", availableRefs).setEnabled(availableRefs.size() > 0));
- boolean gcEnabled = GitBlit.getBoolean(Keys.git.enableGarbageCollection, false);
+ boolean gcEnabled = app().settings().getBoolean(Keys.git.enableGarbageCollection, false);
List<Integer> gcPeriods = Arrays.asList(1, 2, 3, 4, 5, 7, 10, 14 );
form.add(new DropDownChoice<Integer>("gcPeriod", gcPeriods, new GCPeriodRenderer()).setEnabled(gcEnabled));
form.add(new TextField<String>("gcThreshold").setEnabled(gcEnabled));
@@ -474,15 +473,15 @@ public class EditRepositoryPage extends RootSubPage {
form.add(teamsPalette);
form.add(federationSetsPalette);
form.add(preReceivePalette);
- form.add(new BulletListPanel("inheritedPreReceive", getString("gb.inherited"), GitBlit.self()
+ form.add(new BulletListPanel("inheritedPreReceive", getString("gb.inherited"), app().repositories()
.getPreReceiveScriptsInherited(repositoryModel)));
form.add(postReceivePalette);
- form.add(new BulletListPanel("inheritedPostReceive", getString("gb.inherited"), GitBlit.self()
+ form.add(new BulletListPanel("inheritedPostReceive", getString("gb.inherited"), app().repositories()
.getPostReceiveScriptsInherited(repositoryModel)));
WebMarkupContainer customFieldsSection = new WebMarkupContainer("customFieldsSection");
customFieldsSection.add(customFieldsListView);
- form.add(customFieldsSection.setVisible(!GitBlit.getString(Keys.groovy.customFields, "").isEmpty()));
+ form.add(customFieldsSection.setVisible(!app().settings().getString(Keys.groovy.customFields, "").isEmpty()));
// initial enable/disable of permission controls
if (repositoryModel.accessRestriction.equals(AccessRestrictionType.NONE)) {
@@ -579,8 +578,8 @@ public class EditRepositoryPage extends RootSubPage {
* Repository Owners should be able to edit their repository.
*/
private void checkPermissions(RepositoryModel model) {
- boolean authenticateAdmin = GitBlit.getBoolean(Keys.web.authenticateAdminPages, true);
- boolean allowAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, true);
+ boolean authenticateAdmin = app().settings().getBoolean(Keys.web.authenticateAdminPages, true);
+ boolean allowAdmin = app().settings().getBoolean(Keys.web.allowAdministration, true);
GitBlitWebSession session = GitBlitWebSession.get();
UserModel user = session.getUser();
diff --git a/src/main/java/com/gitblit/wicket/pages/EditTeamPage.java b/src/main/java/com/gitblit/wicket/pages/EditTeamPage.java
index 617aa86b..32905c95 100644
--- a/src/main/java/com/gitblit/wicket/pages/EditTeamPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/EditTeamPage.java
@@ -37,7 +37,6 @@ import org.apache.wicket.model.util.CollectionModel;
import org.apache.wicket.model.util.ListModel;
import com.gitblit.Constants.RegistrantType;
-import com.gitblit.GitBlit;
import com.gitblit.GitBlitException;
import com.gitblit.Keys;
import com.gitblit.models.RegistrantAccessPermission;
@@ -70,7 +69,7 @@ public class EditTeamPage extends RootSubPage {
super(params);
isCreate = false;
String name = WicketUtils.getTeamname(params);
- TeamModel model = GitBlit.self().getTeamModel(name);
+ TeamModel model = app().users().getTeamModel(name);
setupPage(model);
setStatelessHint(false);
setOutputMarkupId(true);
@@ -107,7 +106,7 @@ public class EditTeamPage extends RootSubPage {
// users palette
final Palette<String> users = new Palette<String>("users", new ListModel<String>(
- new ArrayList<String>(teamUsers)), new CollectionModel<String>(GitBlit.self()
+ new ArrayList<String>(teamUsers)), new CollectionModel<String>(app().users()
.getAllUsernames()), new StringChoiceRenderer(), 10, false);
// pre-receive palette
@@ -115,8 +114,8 @@ public class EditTeamPage extends RootSubPage {
preReceiveScripts.addAll(teamModel.preReceiveScripts);
}
final Palette<String> preReceivePalette = new Palette<String>("preReceiveScripts",
- new ListModel<String>(preReceiveScripts), new CollectionModel<String>(GitBlit
- .self().getPreReceiveScriptsUnused(null)), new StringChoiceRenderer(),
+ new ListModel<String>(preReceiveScripts), new CollectionModel<String>(app().repositories()
+ .getPreReceiveScriptsUnused(null)), new StringChoiceRenderer(),
12, true);
// post-receive palette
@@ -124,8 +123,8 @@ public class EditTeamPage extends RootSubPage {
postReceiveScripts.addAll(teamModel.postReceiveScripts);
}
final Palette<String> postReceivePalette = new Palette<String>("postReceiveScripts",
- new ListModel<String>(postReceiveScripts), new CollectionModel<String>(GitBlit
- .self().getPostReceiveScriptsUnused(null)), new StringChoiceRenderer(),
+ new ListModel<String>(postReceiveScripts), new CollectionModel<String>(app().repositories()
+ .getPostReceiveScriptsUnused(null)), new StringChoiceRenderer(),
12, true);
Form<TeamModel> form = new Form<TeamModel>("editForm", model) {
@@ -145,7 +144,7 @@ public class EditTeamPage extends RootSubPage {
return;
}
if (isCreate) {
- TeamModel model = GitBlit.self().getTeamModel(teamname);
+ TeamModel model = app().users().getTeamModel(teamname);
if (model != null) {
error(MessageFormat.format(getString("gb.teamNameUnavailable"), teamname));
return;
@@ -197,7 +196,7 @@ public class EditTeamPage extends RootSubPage {
teamModel.postReceiveScripts.addAll(postReceiveScripts);
try {
- GitBlit.self().updateTeamModel(oldName, teamModel, isCreate);
+ app().users().updateTeamModel(oldName, teamModel, isCreate);
} catch (GitBlitException e) {
error(e.getMessage());
return;
@@ -217,12 +216,12 @@ public class EditTeamPage extends RootSubPage {
form.add(new SimpleAttributeModifier("autocomplete", "off"));
// not all user services support manipulating team memberships
- boolean editMemberships = GitBlit.self().supportsTeamMembershipChanges(null);
+ boolean editMemberships = app().users().supportsTeamMembershipChanges(null);
// field names reflective match TeamModel fields
form.add(new TextField<String>("name"));
form.add(new CheckBox("canAdmin"));
- form.add(new CheckBox("canFork").setEnabled(GitBlit.getBoolean(Keys.web.allowForking, true)));
+ form.add(new CheckBox("canFork").setEnabled(app().settings().getBoolean(Keys.web.allowForking, true)));
form.add(new CheckBox("canCreate"));
form.add(users.setEnabled(editMemberships));
mailingLists = new Model<String>(teamModel.mailingLists == null ? ""
@@ -232,10 +231,10 @@ public class EditTeamPage extends RootSubPage {
form.add(new RegistrantPermissionsPanel("repositories", RegistrantType.REPOSITORY,
repos, permissions, getAccessPermissions()));
form.add(preReceivePalette);
- form.add(new BulletListPanel("inheritedPreReceive", "inherited", GitBlit.self()
+ form.add(new BulletListPanel("inheritedPreReceive", "inherited", app().repositories()
.getPreReceiveScriptsInherited(null)));
form.add(postReceivePalette);
- form.add(new BulletListPanel("inheritedPostReceive", "inherited", GitBlit.self()
+ form.add(new BulletListPanel("inheritedPostReceive", "inherited", app().repositories()
.getPostReceiveScriptsInherited(null)));
form.add(new Button("save"));
diff --git a/src/main/java/com/gitblit/wicket/pages/EditUserPage.java b/src/main/java/com/gitblit/wicket/pages/EditUserPage.java
index 6838c196..d0e52f46 100644
--- a/src/main/java/com/gitblit/wicket/pages/EditUserPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/EditUserPage.java
@@ -35,7 +35,6 @@ import org.apache.wicket.model.util.CollectionModel;
import org.apache.wicket.model.util.ListModel;
import com.gitblit.Constants.RegistrantType;
-import com.gitblit.GitBlit;
import com.gitblit.GitBlitException;
import com.gitblit.Keys;
import com.gitblit.models.RegistrantAccessPermission;
@@ -55,9 +54,9 @@ public class EditUserPage extends RootSubPage {
public EditUserPage() {
// create constructor
super();
- if (!GitBlit.self().supportsAddUser()) {
+ if (!app().users().supportsAddUser()) {
error(MessageFormat.format(getString("gb.userServiceDoesNotPermitAddUser"),
- GitBlit.getString(Keys.realm.userService, "${baseFolder}/users.conf")), true);
+ app().settings().getString(Keys.realm.userService, "${baseFolder}/users.conf")), true);
}
isCreate = true;
setupPage(new UserModel(""));
@@ -70,7 +69,7 @@ public class EditUserPage extends RootSubPage {
super(params);
isCreate = false;
String name = WicketUtils.getUsername(params);
- UserModel model = GitBlit.self().getUserModel(name);
+ UserModel model = app().users().getUserModel(name);
setupPage(model);
setStatelessHint(false);
setOutputMarkupId(true);
@@ -107,10 +106,10 @@ public class EditUserPage extends RootSubPage {
Collections.sort(userTeams);
final String oldName = userModel.username;
- final List<RegistrantAccessPermission> permissions = GitBlit.self().getUserAccessPermissions(userModel);
+ final List<RegistrantAccessPermission> permissions = app().repositories().getUserAccessPermissions(userModel);
final Palette<String> teams = new Palette<String>("teams", new ListModel<String>(
- new ArrayList<String>(userTeams)), new CollectionModel<String>(GitBlit.self()
+ new ArrayList<String>(userTeams)), new CollectionModel<String>(app().users()
.getAllTeamnames()), new StringChoiceRenderer(), 10, false);
Form<UserModel> form = new Form<UserModel>("editForm", model) {
@@ -131,7 +130,7 @@ public class EditUserPage extends RootSubPage {
userModel.username = userModel.username.toLowerCase();
String username = userModel.username;
if (isCreate) {
- UserModel model = GitBlit.self().getUserModel(username);
+ UserModel model = app().users().getUserModel(username);
if (model != null) {
error(MessageFormat.format(getString("gb.usernameUnavailable"), username));
return;
@@ -139,7 +138,7 @@ public class EditUserPage extends RootSubPage {
}
boolean rename = !StringUtils.isEmpty(oldName)
&& !oldName.equalsIgnoreCase(username);
- if (GitBlit.self().supportsCredentialChanges(userModel)) {
+ if (app().users().supportsCredentialChanges(userModel)) {
if (!userModel.password.equals(confirmPassword.getObject())) {
error(getString("gb.passwordsDoNotMatch"));
return;
@@ -149,7 +148,7 @@ public class EditUserPage extends RootSubPage {
&& !password.toUpperCase().startsWith(StringUtils.COMBINED_MD5_TYPE)) {
// This is a plain text password.
// Check length.
- int minLength = GitBlit.getInteger(Keys.realm.minPasswordLength, 5);
+ int minLength = app().settings().getInteger(Keys.realm.minPasswordLength, 5);
if (minLength < 4) {
minLength = 4;
}
@@ -160,7 +159,7 @@ public class EditUserPage extends RootSubPage {
}
// Optionally store the password MD5 digest.
- String type = GitBlit.getString(Keys.realm.passwordStorage, "md5");
+ String type = app().settings().getString(Keys.realm.passwordStorage, "md5");
if (type.equalsIgnoreCase("md5")) {
// store MD5 digest of password
userModel.password = StringUtils.MD5_TYPE
@@ -185,7 +184,7 @@ public class EditUserPage extends RootSubPage {
Iterator<String> selectedTeams = teams.getSelectedChoices();
userModel.teams.clear();
while (selectedTeams.hasNext()) {
- TeamModel team = GitBlit.self().getTeamModel(selectedTeams.next());
+ TeamModel team = app().users().getTeamModel(selectedTeams.next());
if (team == null) {
continue;
}
@@ -193,7 +192,7 @@ public class EditUserPage extends RootSubPage {
}
try {
- GitBlit.self().updateUserModel(oldName, userModel, isCreate);
+ app().users().updateUserModel(oldName, userModel, isCreate);
} catch (GitBlitException e) {
error(e.getMessage());
return;
@@ -215,16 +214,16 @@ public class EditUserPage extends RootSubPage {
form.add(new SimpleAttributeModifier("autocomplete", "off"));
// not all user services support manipulating username and password
- boolean editCredentials = GitBlit.self().supportsCredentialChanges(userModel);
+ boolean editCredentials = app().users().supportsCredentialChanges(userModel);
// not all user services support manipulating display name
- boolean editDisplayName = GitBlit.self().supportsDisplayNameChanges(userModel);
+ boolean editDisplayName = app().users().supportsDisplayNameChanges(userModel);
// not all user services support manipulating email address
- boolean editEmailAddress = GitBlit.self().supportsEmailAddressChanges(userModel);
+ boolean editEmailAddress = app().users().supportsEmailAddressChanges(userModel);
// not all user services support manipulating team memberships
- boolean editTeams = GitBlit.self().supportsTeamMembershipChanges(userModel);
+ boolean editTeams = app().users().supportsTeamMembershipChanges(userModel);
// field names reflective match UserModel fields
form.add(new TextField<String>("username").setEnabled(editCredentials));
@@ -238,7 +237,7 @@ public class EditUserPage extends RootSubPage {
form.add(new TextField<String>("displayName").setEnabled(editDisplayName));
form.add(new TextField<String>("emailAddress").setEnabled(editEmailAddress));
form.add(new CheckBox("canAdmin"));
- form.add(new CheckBox("canFork").setEnabled(GitBlit.getBoolean(Keys.web.allowForking, true)));
+ form.add(new CheckBox("canFork").setEnabled(app().settings().getBoolean(Keys.web.allowForking, true)));
form.add(new CheckBox("canCreate"));
form.add(new CheckBox("excludeFromFederation"));
form.add(new RegistrantPermissionsPanel("repositories", RegistrantType.REPOSITORY, repos, permissions, getAccessPermissions()));
diff --git a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java
index 4e05fad6..9e4d355c 100644
--- a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java
@@ -24,7 +24,6 @@ import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.protocol.http.WebRequest;
-import com.gitblit.GitBlit;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.RepositoryUrl;
import com.gitblit.models.UserModel;
@@ -41,7 +40,7 @@ public class EmptyRepositoryPage extends RootPage {
setVersioned(false);
String repositoryName = WicketUtils.getRepositoryName(params);
- RepositoryModel repository = GitBlit.self().getRepositoryModel(repositoryName);
+ RepositoryModel repository = app().repositories().getRepositoryModel(repositoryName);
if (repository == null) {
error(getString("gb.canNotLoadRepository") + " " + repositoryName, true);
}
@@ -59,7 +58,7 @@ public class EmptyRepositoryPage extends RootPage {
}
HttpServletRequest req = ((WebRequest) getRequest()).getHttpServletRequest();
- List<RepositoryUrl> repositoryUrls = GitBlit.self().getRepositoryUrls(req, user, repository);
+ List<RepositoryUrl> repositoryUrls = app().repositories().getRepositoryUrls(req, user, repository);
RepositoryUrl primaryUrl = repositoryUrls.size() == 0 ? null : repositoryUrls.get(0);
String url = primaryUrl != null ? primaryUrl.url : "";
diff --git a/src/main/java/com/gitblit/wicket/pages/FederationPage.java b/src/main/java/com/gitblit/wicket/pages/FederationPage.java
index 1f98c172..a8342938 100644
--- a/src/main/java/com/gitblit/wicket/pages/FederationPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/FederationPage.java
@@ -15,7 +15,6 @@
*/
package com.gitblit.wicket.pages;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.wicket.panels.FederationProposalsPanel;
import com.gitblit.wicket.panels.FederationRegistrationsPanel;
@@ -27,7 +26,7 @@ public class FederationPage extends RootPage {
super();
setupPage("", "");
- boolean showFederation = showAdmin && GitBlit.canFederate();
+ boolean showFederation = showAdmin && app().federation().canFederate();
add(new FederationTokensPanel("federationTokensPanel", showFederation)
.setVisible(showFederation));
FederationProposalsPanel proposalsPanel = new FederationProposalsPanel(
@@ -38,7 +37,7 @@ public class FederationPage extends RootPage {
proposalsPanel.setVisible(false);
}
- boolean showRegistrations = GitBlit.getBoolean(Keys.web.showFederationRegistrations, false);
+ boolean showRegistrations = app().settings().getBoolean(Keys.web.showFederationRegistrations, false);
FederationRegistrationsPanel registrationsPanel = new FederationRegistrationsPanel(
"federationRegistrationsPanel");
if (showAdmin || showRegistrations) {
diff --git a/src/main/java/com/gitblit/wicket/pages/FederationRegistrationPage.java b/src/main/java/com/gitblit/wicket/pages/FederationRegistrationPage.java
index 42f46943..c26c9757 100644
--- a/src/main/java/com/gitblit/wicket/pages/FederationRegistrationPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/FederationRegistrationPage.java
@@ -24,7 +24,6 @@ import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
-import com.gitblit.GitBlit;
import com.gitblit.models.FederationModel;
import com.gitblit.models.FederationModel.RepositoryStatus;
import com.gitblit.wicket.WicketUtils;
@@ -39,7 +38,7 @@ public class FederationRegistrationPage extends RootSubPage {
String url = WicketUtils.getUrlParameter(params);
String name = WicketUtils.getNameParameter(params);
- FederationModel registration = GitBlit.self().getFederationRegistration(url, name);
+ FederationModel registration = app().federation().getFederationRegistration(url, name);
if (registration == null) {
error(getString("gb.couldNotFindFederationRegistration"), true);
}
diff --git a/src/main/java/com/gitblit/wicket/pages/ForkPage.java b/src/main/java/com/gitblit/wicket/pages/ForkPage.java
index fe316fff..12020128 100644
--- a/src/main/java/com/gitblit/wicket/pages/ForkPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/ForkPage.java
@@ -21,9 +21,9 @@ import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.slf4j.LoggerFactory;
-import com.gitblit.GitBlit;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.UserModel;
+import com.gitblit.wicket.GitBlitWebApp;
import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.GitblitRedirectException;
import com.gitblit.wicket.WicketUtils;
@@ -49,7 +49,7 @@ public class ForkPage extends RepositoryPage {
throw new GitblitRedirectException(SummaryPage.class, WicketUtils.newRepositoryParameter(repository.name));
}
- String fork = GitBlit.self().getFork(user.username, repository.name);
+ String fork = app().repositories().getFork(user.username, repository.name);
if (fork != null) {
// redirect to user's fork
throw new GitblitRedirectException(SummaryPage.class, WicketUtils.newRepositoryParameter(fork));
@@ -62,7 +62,7 @@ public class ForkPage extends RepositoryPage {
session.isForking(true);
// fork it
- ForkThread forker = new ForkThread(repository, session);
+ ForkThread forker = new ForkThread(app(), repository, session);
forker.start();
}
}
@@ -84,10 +84,12 @@ public class ForkPage extends RepositoryPage {
*/
private static class ForkThread extends Thread {
+ private final GitBlitWebApp app;
private final RepositoryModel repository;
private final GitBlitWebSession session;
- public ForkThread(RepositoryModel repository, GitBlitWebSession session) {
+ public ForkThread(GitBlitWebApp app, RepositoryModel repository, GitBlitWebSession session) {
+ this.app = app;
this.repository = repository;
this.session = session;
}
@@ -96,7 +98,7 @@ public class ForkPage extends RepositoryPage {
public void run() {
UserModel user = session.getUser();
try {
- GitBlit.self().fork(repository, user);
+ app.gitblit().fork(repository, user);
} catch (Exception e) {
LoggerFactory.getLogger(ForkPage.class).error(MessageFormat.format("Failed to fork {0} for {1}", repository.name, user.username), e);
} finally {
diff --git a/src/main/java/com/gitblit/wicket/pages/ForksPage.java b/src/main/java/com/gitblit/wicket/pages/ForksPage.java
index 5b5fcc0a..9fd7f4db 100644
--- a/src/main/java/com/gitblit/wicket/pages/ForksPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/ForksPage.java
@@ -27,7 +27,6 @@ import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
import org.eclipse.jgit.lib.PersonIdent;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.ForkModel;
import com.gitblit.models.RepositoryModel;
@@ -45,7 +44,7 @@ public class ForksPage extends RepositoryPage {
final RepositoryModel pageRepository = getRepositoryModel();
- ForkModel root = GitBlit.self().getForkNetwork(pageRepository.name);
+ ForkModel root = app().repositories().getForkNetwork(pageRepository.name);
List<FlatFork> network = flatten(root);
ListDataProvider<FlatFork> forksDp = new ListDataProvider<FlatFork>(network);
@@ -58,7 +57,7 @@ public class ForksPage extends RepositoryPage {
RepositoryModel repository = fork.repository;
if (repository.isPersonalRepository()) {
- UserModel user = GitBlit.self().getUserModel(repository.projectPath.substring(1));
+ UserModel user = app().users().getUserModel(repository.projectPath.substring(1));
if (user == null) {
// user account no longer exists
user = new UserModel(repository.projectPath.substring(1));
@@ -84,7 +83,7 @@ public class ForksPage extends RepositoryPage {
item.add(swatch);
String projectName = repository.projectPath;
if (StringUtils.isEmpty(projectName)) {
- projectName = GitBlit.getString(Keys.web.repositoryRootGroupName, "main");
+ projectName = app().settings().getString(Keys.web.repositoryRootGroupName, "main");
}
if (pageRepository.equals(repository)) {
// do not link to self
diff --git a/src/main/java/com/gitblit/wicket/pages/LogoutPage.java b/src/main/java/com/gitblit/wicket/pages/LogoutPage.java
index ff3b507f..f7be99ae 100644
--- a/src/main/java/com/gitblit/wicket/pages/LogoutPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/LogoutPage.java
@@ -18,7 +18,6 @@ package com.gitblit.wicket.pages;
import org.apache.wicket.protocol.http.WebRequest;
import org.apache.wicket.protocol.http.WebResponse;
-import com.gitblit.GitBlit;
import com.gitblit.models.UserModel;
import com.gitblit.wicket.GitBlitWebSession;
@@ -28,8 +27,8 @@ public class LogoutPage extends BasePage {
super();
GitBlitWebSession session = GitBlitWebSession.get();
UserModel user = session.getUser();
- GitBlit.self().setCookie((WebResponse) getResponse(), null);
- GitBlit.self().logout(user);
+ app().session().setCookie((WebResponse) getResponse(), null);
+ app().session().logout(user);
session.invalidate();
/*
diff --git a/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java b/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java
index 86a426ca..4d4545a5 100644
--- a/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java
@@ -32,7 +32,6 @@ import org.apache.wicket.model.Model;
import org.eclipse.jgit.lib.Constants;
import com.gitblit.Constants.SearchType;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.SearchResult;
@@ -65,7 +64,7 @@ public class LuceneSearchPage extends RootPage {
ArrayList<String> repositories = new ArrayList<String>();
String query = "";
int page = 1;
- int pageSize = GitBlit.getInteger(Keys.web.itemsPerPage, 50);
+ int pageSize = app().settings().getInteger(Keys.web.itemsPerPage, 50);
if (params != null) {
String repository = WicketUtils.getRepositoryName(params);
@@ -100,12 +99,12 @@ public class LuceneSearchPage extends RootPage {
// display user-accessible selections
UserModel user = GitBlitWebSession.get().getUser();
List<String> availableRepositories = new ArrayList<String>();
- for (RepositoryModel model : GitBlit.self().getRepositoryModels(user)) {
+ for (RepositoryModel model : app().repositories().getRepositoryModels(user)) {
if (model.hasCommits && !ArrayUtils.isEmpty(model.indexedBranches)) {
availableRepositories.add(model.name);
}
}
- boolean luceneEnabled = GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true);
+ boolean luceneEnabled = app().settings().getBoolean(Keys.web.allowLuceneIndexing, true);
if (luceneEnabled) {
if (availableRepositories.size() == 0) {
info(getString("gb.noIndexedRepositoriesWarning"));
@@ -158,7 +157,7 @@ public class LuceneSearchPage extends RootPage {
// execute search
final List<SearchResult> results = new ArrayList<SearchResult>();
if (!ArrayUtils.isEmpty(searchRepositories) && !StringUtils.isEmpty(query)) {
- results.addAll(GitBlit.self().search(query, page, pageSize, searchRepositories));
+ results.addAll(app().repositories().search(query, page, pageSize, searchRepositories));
}
// results header
diff --git a/src/main/java/com/gitblit/wicket/pages/MyDashboardPage.java b/src/main/java/com/gitblit/wicket/pages/MyDashboardPage.java
index 8e05b4f0..ba85b822 100644
--- a/src/main/java/com/gitblit/wicket/pages/MyDashboardPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/MyDashboardPage.java
@@ -35,7 +35,6 @@ import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Fragment;
import org.eclipse.jgit.lib.Constants;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.ProjectModel;
import com.gitblit.models.RepositoryModel;
@@ -71,9 +70,9 @@ public class MyDashboardPage extends DashboardPage {
private void setup(PageParameters params) {
setupPage("", "");
// check to see if we should display a login message
- boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, true);
+ boolean authenticateView = app().settings().getBoolean(Keys.web.authenticateViewPages, true);
if (authenticateView && !GitBlitWebSession.get().isLoggedIn()) {
- String messageSource = GitBlit.getString(Keys.web.loginMessage, "gitblit");
+ String messageSource = app().settings().getString(Keys.web.loginMessage, "gitblit");
String message = readMarkdown(messageSource, "login.mkd");
Component repositoriesMessage = new Label("repositoriesMessage", message);
add(repositoriesMessage.setEscapeModelStrings(false));
@@ -83,7 +82,7 @@ public class MyDashboardPage extends DashboardPage {
}
// Load the markdown welcome message
- String messageSource = GitBlit.getString(Keys.web.repositoriesMessage, "gitblit");
+ String messageSource = app().settings().getString(Keys.web.repositoriesMessage, "gitblit");
String message = readMarkdown(messageSource, "welcome.mkd");
Component repositoriesMessage = new Label("repositoriesMessage", message)
.setEscapeModelStrings(false).setVisible(message.length() > 0);
@@ -96,9 +95,9 @@ public class MyDashboardPage extends DashboardPage {
// parameters
int daysBack = params == null ? 0 : WicketUtils.getDaysBack(params);
- int maxDaysBack = GitBlit.getInteger(Keys.web.activityDurationMaximum, 30);
+ int maxDaysBack = app().settings().getInteger(Keys.web.activityDurationMaximum, 30);
if (daysBack < 1) {
- daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);
+ daysBack = app().settings().getInteger(Keys.web.activityDuration, 7);
}
if (maxDaysBack > 0 && daysBack > maxDaysBack) {
daysBack = maxDaysBack;
@@ -168,7 +167,7 @@ public class MyDashboardPage extends DashboardPage {
add(repositoryTabs);
// projects list
- List<ProjectModel> projects = GitBlit.self().getProjectModels(getRepositoryModels(), false);
+ List<ProjectModel> projects = app().projects().getProjectModels(getRepositoryModels(), false);
repositoryTabs.add(new FilterableProjectList("projects", projects));
// active repository list
@@ -208,7 +207,7 @@ public class MyDashboardPage extends DashboardPage {
} else {
// Read user-supplied message
if (!StringUtils.isEmpty(messageSource)) {
- File file = GitBlit.getFileOrFolder(messageSource);
+ File file = app().runtime().getFileOrFolder(messageSource);
if (file.exists()) {
try {
FileInputStream fis = new FileInputStream(file);
diff --git a/src/main/java/com/gitblit/wicket/pages/OverviewPage.java b/src/main/java/com/gitblit/wicket/pages/OverviewPage.java
index f6362c22..efb7f4cf 100644
--- a/src/main/java/com/gitblit/wicket/pages/OverviewPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/OverviewPage.java
@@ -28,7 +28,6 @@ import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
import org.eclipse.jgit.lib.Repository;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.Metric;
import com.gitblit.models.RepositoryModel;
@@ -53,7 +52,7 @@ public class OverviewPage extends RepositoryPage {
public OverviewPage(PageParameters params) {
super(params);
- int numberRefs = GitBlit.getInteger(Keys.web.summaryRefsCount, 5);
+ int numberRefs = app().settings().getInteger(Keys.web.summaryRefsCount, 5);
Repository r = getRepository();
final RepositoryModel model = getRepositoryModel();
@@ -64,8 +63,8 @@ public class OverviewPage extends RepositoryPage {
List<Metric> metrics = null;
Metric metricsTotal = null;
- if (!model.skipSummaryMetrics && GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {
- metrics = GitBlit.self().getRepositoryDefaultMetrics(model, r);
+ if (!model.skipSummaryMetrics && app().settings().getBoolean(Keys.web.generateActivityGraph, true)) {
+ metrics = app().repositories().getRepositoryDefaultMetrics(model, r);
metricsTotal = metrics.remove(0);
}
@@ -83,7 +82,7 @@ public class OverviewPage extends RepositoryPage {
@Override
public void populateItem(final Item<String> item) {
String ownername = item.getModelObject();
- UserModel ownerModel = GitBlit.self().getUserModel(ownername);
+ UserModel ownerModel = app().users().getUserModel(ownername);
if (ownerModel != null) {
item.add(new LinkPanel("owner", null, ownerModel.getDisplayName(), UserPage.class,
WicketUtils.newUsernameParameter(ownerModel.username)).setRenderBodyOnly(true));
@@ -117,7 +116,7 @@ public class OverviewPage extends RepositoryPage {
add(new RepositoryUrlPanel("repositoryUrlPanel", false, user, model));
- int reflogCount = GitBlit.getInteger(Keys.web.overviewReflogCount, 5);
+ int reflogCount = app().settings().getInteger(Keys.web.overviewReflogCount, 5);
ReflogPanel reflog = new ReflogPanel("reflogPanel", getRepositoryModel(), r, reflogCount, 0);
add(reflog);
add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs).hideIfEmpty());
@@ -134,7 +133,7 @@ public class OverviewPage extends RepositoryPage {
private void insertActivityGraph(List<Metric> metrics) {
if ((metrics != null) && (metrics.size() > 0)
- && GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {
+ && app().settings().getBoolean(Keys.web.generateActivityGraph, true)) {
// daily line chart
GoogleChart chart = new GoogleLineChart("chartDaily", "", "unit",
diff --git a/src/main/java/com/gitblit/wicket/pages/PatchPage.java b/src/main/java/com/gitblit/wicket/pages/PatchPage.java
index be959d01..ece41367 100644
--- a/src/main/java/com/gitblit/wicket/pages/PatchPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/PatchPage.java
@@ -16,12 +16,10 @@
package com.gitblit.wicket.pages;
import org.apache.wicket.PageParameters;
-import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
-import com.gitblit.GitBlit;
import com.gitblit.utils.DiffUtils;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.StringUtils;
@@ -31,7 +29,7 @@ import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.WicketUtils;
@CacheControl(LastModified.BOOT)
-public class PatchPage extends WebPage {
+public class PatchPage extends SessionPage {
public PatchPage(PageParameters params) {
super(params);
@@ -47,7 +45,7 @@ public class PatchPage extends WebPage {
final String objectId = WicketUtils.getObject(params);
final String blobPath = WicketUtils.getPath(params);
- Repository r = GitBlit.self().getRepository(repositoryName);
+ Repository r = app().repositories().getRepository(repositoryName);
if (r == null) {
GitBlitWebSession.get().cacheErrorMessage(getString("gb.canNotLoadRepository") + " " + repositoryName);
redirectToInterceptPage(new RepositoriesPage());
diff --git a/src/main/java/com/gitblit/wicket/pages/ProjectPage.java b/src/main/java/com/gitblit/wicket/pages/ProjectPage.java
index 19588a95..22396bec 100644
--- a/src/main/java/com/gitblit/wicket/pages/ProjectPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/ProjectPage.java
@@ -25,7 +25,6 @@ import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.ExternalLink;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.SyndicationServlet;
import com.gitblit.models.ProjectModel;
@@ -87,7 +86,7 @@ public class ProjectPage extends DashboardPage {
private void setup(PageParameters params) {
setupPage("", "");
// check to see if we should display a login message
- boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, true);
+ boolean authenticateView = app().settings().getBoolean(Keys.web.authenticateViewPages, true);
if (authenticateView && !GitBlitWebSession.get().isLoggedIn()) {
authenticationError("Please login");
return;
@@ -130,7 +129,7 @@ public class ProjectPage extends DashboardPage {
}
int daysBack = params == null ? 0 : WicketUtils.getDaysBack(params);
if (daysBack < 1) {
- daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);
+ daysBack = app().settings().getInteger(Keys.web.activityDuration, 7);
}
// reset the daysback parameter so that we have a complete project
// repository list. the recent activity will be built up by the
@@ -186,7 +185,7 @@ public class ProjectPage extends DashboardPage {
protected List<ProjectModel> getProjectModels() {
if (projectModels.isEmpty()) {
List<RepositoryModel> repositories = getRepositoryModels();
- List<ProjectModel> projects = GitBlit.self().getProjectModels(repositories, false);
+ List<ProjectModel> projects = app().projects().getProjectModels(repositories, false);
projectModels.addAll(projects);
}
return projectModels;
diff --git a/src/main/java/com/gitblit/wicket/pages/ProjectsPage.java b/src/main/java/com/gitblit/wicket/pages/ProjectsPage.java
index e5000462..77d49846 100644
--- a/src/main/java/com/gitblit/wicket/pages/ProjectsPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/ProjectsPage.java
@@ -23,7 +23,6 @@ import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.ProjectModel;
import com.gitblit.wicket.GitBlitWebSession;
@@ -57,13 +56,13 @@ public class ProjectsPage extends RootPage {
@Override
protected List<ProjectModel> getProjectModels() {
- return GitBlit.self().getProjectModels(getRepositoryModels(), false);
+ return app().projects().getProjectModels(getRepositoryModels(), false);
}
private void setup(PageParameters params) {
setupPage("", "");
// check to see if we should display a login message
- boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, true);
+ boolean authenticateView = app().settings().getBoolean(Keys.web.authenticateViewPages, true);
if (authenticateView && !GitBlitWebSession.get().isLoggedIn()) {
add(new Label("projectsPanel"));
return;
diff --git a/src/main/java/com/gitblit/wicket/pages/RawPage.java b/src/main/java/com/gitblit/wicket/pages/RawPage.java
index 17837649..ac4af6d5 100644
--- a/src/main/java/com/gitblit/wicket/pages/RawPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/RawPage.java
@@ -31,7 +31,6 @@ import org.eclipse.jgit.revwalk.RevCommit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.UserModel;
@@ -66,11 +65,11 @@ public class RawPage extends SessionPage {
final String repositoryName = WicketUtils.getRepositoryName(params);
final String objectId = WicketUtils.getObject(params);
final String blobPath = WicketUtils.getPath(params);
- String[] encodings = GitBlit.getEncodings();
+ String[] encodings = getEncodings();
GitBlitWebSession session = GitBlitWebSession.get();
UserModel user = session.getUser();
- RepositoryModel model = GitBlit.self().getRepositoryModel(user, repositoryName);
+ RepositoryModel model = app().repositories().getRepositoryModel(user, repositoryName);
if (model == null) {
// user does not have permission
error(getString("gb.canNotLoadRepository") + " " + repositoryName);
@@ -78,7 +77,7 @@ public class RawPage extends SessionPage {
return;
}
- Repository r = GitBlit.self().getRepository(repositoryName);
+ Repository r = app().repositories().getRepository(repositoryName);
if (r == null) {
error(getString("gb.canNotLoadRepository") + " " + repositoryName);
redirectToInterceptPage(new RepositoriesPage());
@@ -112,10 +111,10 @@ public class RawPage extends SessionPage {
// Map the extensions to types
Map<String, Integer> map = new HashMap<String, Integer>();
- for (String ext : GitBlit.getStrings(Keys.web.imageExtensions)) {
+ for (String ext : app().settings().getStrings(Keys.web.imageExtensions)) {
map.put(ext.toLowerCase(), 2);
}
- for (String ext : GitBlit.getStrings(Keys.web.binaryExtensions)) {
+ for (String ext : app().settings().getStrings(Keys.web.binaryExtensions)) {
map.put(ext.toLowerCase(), 3);
}
diff --git a/src/main/java/com/gitblit/wicket/pages/RepositoriesPage.java b/src/main/java/com/gitblit/wicket/pages/RepositoriesPage.java
index b446279a..70266f8f 100644
--- a/src/main/java/com/gitblit/wicket/pages/RepositoriesPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/RepositoriesPage.java
@@ -28,7 +28,6 @@ import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.eclipse.jgit.lib.Constants;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.RepositoryModel;
import com.gitblit.utils.MarkdownUtils;
@@ -63,9 +62,9 @@ public class RepositoriesPage extends RootPage {
private void setup(PageParameters params) {
setupPage("", "");
// check to see if we should display a login message
- boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, true);
+ boolean authenticateView = app().settings().getBoolean(Keys.web.authenticateViewPages, true);
if (authenticateView && !GitBlitWebSession.get().isLoggedIn()) {
- String messageSource = GitBlit.getString(Keys.web.loginMessage, "gitblit");
+ String messageSource = app().settings().getString(Keys.web.loginMessage, "gitblit");
String message = readMarkdown(messageSource, "login.mkd");
Component repositoriesMessage = new Label("repositoriesMessage", message);
add(repositoriesMessage.setEscapeModelStrings(false));
@@ -74,7 +73,7 @@ public class RepositoriesPage extends RootPage {
}
// Load the markdown welcome message
- String messageSource = GitBlit.getString(Keys.web.repositoriesMessage, "gitblit");
+ String messageSource = app().settings().getString(Keys.web.repositoriesMessage, "gitblit");
String message = readMarkdown(messageSource, "welcome.mkd");
Component repositoriesMessage = new Label("repositoriesMessage", message)
.setEscapeModelStrings(false).setVisible(message.length() > 0);
@@ -120,7 +119,7 @@ public class RepositoriesPage extends RootPage {
} else {
// Read user-supplied message
if (!StringUtils.isEmpty(messageSource)) {
- File file = GitBlit.getFileOrFolder(messageSource);
+ File file = app().runtime().getFileOrFolder(messageSource);
if (file.exists()) {
try {
FileInputStream fis = new FileInputStream(file);
diff --git a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
index 93af1bef..e19c1955 100644
--- a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
@@ -46,7 +46,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.gitblit.Constants;
-import com.gitblit.GitBlit;
import com.gitblit.GitBlitException;
import com.gitblit.Keys;
import com.gitblit.PagesServlet;
@@ -60,6 +59,7 @@ import com.gitblit.models.UserRepositoryPreferences;
import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.DeepCopier;
import com.gitblit.utils.JGitUtils;
+import com.gitblit.utils.MessageProcessor;
import com.gitblit.utils.RefLogUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.CacheControl;
@@ -97,7 +97,7 @@ public abstract class RepositoryPage extends RootPage {
repositoryName = WicketUtils.getRepositoryName(params);
String root =StringUtils.getFirstPathElement(repositoryName);
if (StringUtils.isEmpty(root)) {
- projectName = GitBlit.getString(Keys.web.repositoryRootGroupName, "main");
+ projectName = app().settings().getString(Keys.web.repositoryRootGroupName, "main");
} else {
projectName = root;
}
@@ -139,7 +139,7 @@ public abstract class RepositoryPage extends RootPage {
UserRepositoryPreferences prefs = user.getPreferences().getRepositoryPreferences(getRepositoryModel().name);
prefs.starred = star;
try {
- GitBlit.self().updateUserModel(user.username, user, false);
+ app().users().updateUserModel(user.username, user, false);
} catch (GitBlitException e) {
logger.error("Failed to update user " + user.username, e);
error(getString("gb.failedToUpdateUser"), false);
@@ -176,6 +176,10 @@ public abstract class RepositoryPage extends RootPage {
return getClass();
}
+ protected MessageProcessor messageProcessor() {
+ return new MessageProcessor(app().settings());
+ }
+
private Map<String, PageRegistration> registerPages() {
PageParameters params = null;
if (!StringUtils.isEmpty(repositoryName)) {
@@ -198,7 +202,7 @@ public abstract class RepositoryPage extends RootPage {
pages.put("tree", new PageRegistration("gb.tree", TreePage.class, params));
pages.put("docs", new PageRegistration("gb.docs", DocsPage.class, params, true));
pages.put("compare", new PageRegistration("gb.compare", ComparePage.class, params, true));
- if (GitBlit.getBoolean(Keys.web.allowForking, true)) {
+ if (app().settings().getBoolean(Keys.web.allowForking, true)) {
pages.put("forks", new PageRegistration("gb.forks", ForksPage.class, params, true));
}
@@ -212,11 +216,11 @@ public abstract class RepositoryPage extends RootPage {
// Conditionally add edit link
showAdmin = false;
- if (GitBlit.getBoolean(Keys.web.authenticateAdminPages, true)) {
- boolean allowAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, false);
+ if (app().settings().getBoolean(Keys.web.authenticateAdminPages, true)) {
+ boolean allowAdmin = app().settings().getBoolean(Keys.web.allowAdministration, false);
showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin();
} else {
- showAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, false);
+ showAdmin = app().settings().getBoolean(Keys.web.allowAdministration, false);
}
isOwner = GitBlitWebSession.get().isLoggedIn()
&& (model.isOwner(GitBlitWebSession.get()
@@ -225,13 +229,13 @@ public abstract class RepositoryPage extends RootPage {
}
protected boolean allowForkControls() {
- return GitBlit.getBoolean(Keys.web.allowForking, true);
+ return app().settings().getBoolean(Keys.web.allowForking, true);
}
@Override
protected void setupPage(String repositoryName, String pageName) {
String projectName = StringUtils.getFirstPathElement(repositoryName);
- ProjectModel project = GitBlit.self().getProjectModel(projectName);
+ ProjectModel project = app().projects().getProjectModel(projectName);
if (project.isUserProject()) {
// user-as-project
add(new LinkPanel("projectTitle", null, project.getDisplayName(),
@@ -267,7 +271,7 @@ public abstract class RepositoryPage extends RootPage {
add(new Label("originRepository").setVisible(false));
}
} else {
- RepositoryModel origin = GitBlit.self().getRepositoryModel(model.originRepository);
+ RepositoryModel origin = app().repositories().getRepositoryModel(model.originRepository);
if (origin == null) {
// no origin repository
add(new Label("originRepository").setVisible(false));
@@ -311,7 +315,7 @@ public abstract class RepositoryPage extends RootPage {
add(new ExternalLink("forkLink", "").setVisible(false));
add(new ExternalLink("myForkLink", "").setVisible(false));
} else {
- String fork = GitBlit.self().getFork(user.username, model.name);
+ String fork = app().repositories().getFork(user.username, model.name);
boolean hasFork = fork != null;
boolean canFork = user.canFork(model);
@@ -363,7 +367,7 @@ public abstract class RepositoryPage extends RootPage {
protected Repository getRepository() {
if (r == null) {
- Repository r = GitBlit.self().getRepository(repositoryName);
+ Repository r = app().repositories().getRepository(repositoryName);
if (r == null) {
error(getString("gb.canNotLoadRepository") + " " + repositoryName, true);
return null;
@@ -375,10 +379,10 @@ public abstract class RepositoryPage extends RootPage {
protected RepositoryModel getRepositoryModel() {
if (m == null) {
- RepositoryModel model = GitBlit.self().getRepositoryModel(
+ RepositoryModel model = app().repositories().getRepositoryModel(
GitBlitWebSession.get().getUser(), repositoryName);
if (model == null) {
- if (GitBlit.self().hasRepository(repositoryName, true)) {
+ if (app().repositories().hasRepository(repositoryName, true)) {
// has repository, but unauthorized
authenticationError(getString("gb.unauthorizedAccessForRepository") + " " + repositoryName);
} else {
@@ -450,7 +454,7 @@ public abstract class RepositoryPage extends RootPage {
return model;
} else {
// extract the repository name from the clone url
- List<String> patterns = GitBlit.getStrings(Keys.git.submoduleUrlPatterns);
+ List<String> patterns = app().settings().getStrings(Keys.git.submoduleUrlPatterns);
String submoduleName = StringUtils.extractRepositoryPath(model.url, patterns.toArray(new String[0]));
// determine the current path for constructing paths relative
@@ -489,7 +493,7 @@ public abstract class RepositoryPage extends RootPage {
// create a unique, ordered set of candidate paths
Set<String> paths = new LinkedHashSet<String>(candidates);
for (String candidate : paths) {
- if (GitBlit.self().hasRepository(candidate)) {
+ if (app().repositories().hasRepository(candidate)) {
model.hasSubmodule = true;
model.gitblitPath = candidate;
return model;
@@ -503,7 +507,7 @@ public abstract class RepositoryPage extends RootPage {
}
protected String getShortObjectId(String objectId) {
- return objectId.substring(0, GitBlit.getInteger(Keys.web.shortCommitIdLength, 6));
+ return objectId.substring(0, app().settings().getInteger(Keys.web.shortCommitIdLength, 6));
}
protected void addRefs(Repository r, RevCommit c) {
@@ -512,7 +516,7 @@ public abstract class RepositoryPage extends RootPage {
protected void addFullText(String wicketId, String text) {
RepositoryModel model = getRepositoryModel();
- String content = GitBlit.self().processCommitMessage(model, text);
+ String content = messageProcessor().processCommitMessage(model, text);
String html;
switch (model.commitMessageRenderer) {
case MARKDOWN:
@@ -533,7 +537,7 @@ public abstract class RepositoryPage extends RootPage {
String address = identity == null ? "" : identity.getEmailAddress();
name = StringUtils.removeNewlines(name);
address = StringUtils.removeNewlines(address);
- boolean showEmail = GitBlit.getBoolean(Keys.web.showEmailAddresses, false);
+ boolean showEmail = app().settings().getBoolean(Keys.web.showEmailAddresses, false);
if (!showEmail || StringUtils.isEmpty(name) || StringUtils.isEmpty(address)) {
String value = name;
if (StringUtils.isEmpty(value)) {
@@ -664,7 +668,7 @@ public abstract class RepositoryPage extends RootPage {
DropDownChoice<Constants.SearchType> searchType = new DropDownChoice<Constants.SearchType>(
"searchType", Arrays.asList(Constants.SearchType.values()));
searchType.setModel(searchTypeModel);
- add(searchType.setVisible(GitBlit.getBoolean(Keys.web.showSearchTypeSelection, false)));
+ add(searchType.setVisible(app().settings().getBoolean(Keys.web.showSearchTypeSelection, false)));
TextField<String> searchBox = new TextField<String>("searchBox", searchBoxModel);
add(searchBox);
}
@@ -695,8 +699,8 @@ public abstract class RepositoryPage extends RootPage {
}
}
Class<? extends BasePage> searchPageClass = GitSearchPage.class;
- RepositoryModel model = GitBlit.self().getRepositoryModel(repositoryName);
- if (GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true)
+ RepositoryModel model = app().repositories().getRepositoryModel(repositoryName);
+ if (app().settings().getBoolean(Keys.web.allowLuceneIndexing, true)
&& !ArrayUtils.isEmpty(model.indexedBranches)) {
// this repository is Lucene-indexed
searchPageClass = LuceneSearchPage.class;
diff --git a/src/main/java/com/gitblit/wicket/pages/ReviewProposalPage.java b/src/main/java/com/gitblit/wicket/pages/ReviewProposalPage.java
index ebe15304..8aec9e63 100644
--- a/src/main/java/com/gitblit/wicket/pages/ReviewProposalPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/ReviewProposalPage.java
@@ -23,7 +23,6 @@ import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import com.gitblit.Constants.FederationToken;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.FederationProposal;
import com.gitblit.models.RepositoryModel;
@@ -37,14 +36,12 @@ public class ReviewProposalPage extends RootSubPage {
private final String PROPS_PATTERN = "{0} = {1}\n";
- 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";
-
public ReviewProposalPage(PageParameters params) {
super(params);
final String token = WicketUtils.getToken(params);
- FederationProposal proposal = GitBlit.self().getPendingFederationProposal(token);
+ FederationProposal proposal = app().federation().getPendingFederationProposal(token);
if (proposal == null) {
error(getString("gb.couldNotFindFederationProposal"), true);
}
@@ -58,14 +55,7 @@ public class ReviewProposalPage extends RootSubPage {
add(new Label("token", proposal.token));
add(new Label("tokenType", proposal.tokenType.name()));
- String p;
- if (GitBlit.isGO()) {
- // gitblit.properties definition
- p = PROPS_PATTERN;
- } else {
- // web.xml definition
- p = WEBXML_PATTERN;
- }
+ String p = PROPS_PATTERN;
// build proposed definition
StringBuilder sb = new StringBuilder();
@@ -77,7 +67,7 @@ public class ReviewProposalPage extends RootSubPage {
sb.append(asParam(p, proposal.name, "mergeAccounts", "false"));
}
sb.append(asParam(p, proposal.name, "frequency",
- GitBlit.getString(Keys.federation.defaultFrequency, "60 mins")));
+ app().settings().getString(Keys.federation.defaultFrequency, "60 mins")));
sb.append(asParam(p, proposal.name, "folder", proposal.name));
sb.append(asParam(p, proposal.name, "bare", "true"));
sb.append(asParam(p, proposal.name, "mirror", "true"));
diff --git a/src/main/java/com/gitblit/wicket/pages/RootPage.java b/src/main/java/com/gitblit/wicket/pages/RootPage.java
index a59e2022..98a8cb32 100644
--- a/src/main/java/com/gitblit/wicket/pages/RootPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/RootPage.java
@@ -46,7 +46,6 @@ import org.apache.wicket.model.Model;
import org.apache.wicket.protocol.http.WebResponse;
import com.gitblit.Constants;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.TeamModel;
@@ -97,22 +96,22 @@ public abstract class RootPage extends BasePage {
StringBuilder buffer = new StringBuilder();
buffer.append("<style type=\"text/css\">\n");
buffer.append(".navbar-inner {\n");
- final String headerBackground = GitBlit.getString(Keys.web.headerBackgroundColor, null);
+ final String headerBackground = app().settings().getString(Keys.web.headerBackgroundColor, null);
if (!StringUtils.isEmpty(headerBackground)) {
buffer.append(MessageFormat.format("background-color: {0};\n", headerBackground));
}
- final String headerBorder = GitBlit.getString(Keys.web.headerBorderColor, null);
+ final String headerBorder = app().settings().getString(Keys.web.headerBorderColor, null);
if (!StringUtils.isEmpty(headerBorder)) {
buffer.append(MessageFormat.format("border-bottom: 1px solid {0} !important;\n", headerBorder));
}
buffer.append("}\n");
- final String headerBorderFocus = GitBlit.getString(Keys.web.headerBorderFocusColor, null);
+ final String headerBorderFocus = app().settings().getString(Keys.web.headerBorderFocusColor, null);
if (!StringUtils.isEmpty(headerBorderFocus)) {
buffer.append(".navbar ul li:focus, .navbar .active {\n");
buffer.append(MessageFormat.format("border-bottom: 4px solid {0};\n", headerBorderFocus));
buffer.append("}\n");
}
- final String headerForeground = GitBlit.getString(Keys.web.headerForegroundColor, null);
+ final String headerForeground = app().settings().getString(Keys.web.headerForegroundColor, null);
if (!StringUtils.isEmpty(headerForeground)) {
buffer.append(".navbar ul.nav li a {\n");
buffer.append(MessageFormat.format("color: {0};\n", headerForeground));
@@ -121,7 +120,7 @@ public abstract class RootPage extends BasePage {
buffer.append(MessageFormat.format("color: {0};\n", headerForeground));
buffer.append("}\n");
}
- final String headerHover = GitBlit.getString(Keys.web.headerHoverColor, null);
+ final String headerHover = app().settings().getString(Keys.web.headerHoverColor, null);
if (!StringUtils.isEmpty(headerHover)) {
buffer.append(".navbar ul.nav li a:hover {\n");
buffer.append(MessageFormat.format("color: {0} !important;\n", headerHover));
@@ -132,9 +131,9 @@ public abstract class RootPage extends BasePage {
}
}));
- boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, false);
- boolean authenticateAdmin = GitBlit.getBoolean(Keys.web.authenticateAdminPages, true);
- boolean allowAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, true);
+ boolean authenticateView = app().settings().getBoolean(Keys.web.authenticateViewPages, false);
+ boolean authenticateAdmin = app().settings().getBoolean(Keys.web.authenticateAdminPages, true);
+ boolean allowAdmin = app().settings().getBoolean(Keys.web.allowAdministration, true);
if (authenticateAdmin) {
showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin();
@@ -163,8 +162,8 @@ public abstract class RootPage extends BasePage {
add(new Label("userPanel").setVisible(false));
}
- boolean showRegistrations = GitBlit.canFederate()
- && GitBlit.getBoolean(Keys.web.showFederationRegistrations, false);
+ boolean showRegistrations = app().federation().canFederate()
+ && app().settings().getBoolean(Keys.web.showFederationRegistrations, false);
// navigation links
List<PageRegistration> pages = new ArrayList<PageRegistration>();
@@ -174,7 +173,7 @@ public abstract class RootPage extends BasePage {
pages.add(new PageRegistration("gb.repositories", RepositoriesPage.class,
getRootPageParameters()));
pages.add(new PageRegistration("gb.activity", ActivityPage.class, getRootPageParameters()));
- if (GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true)) {
+ if (app().settings().getBoolean(Keys.web.allowLuceneIndexing, true)) {
pages.add(new PageRegistration("gb.search", LuceneSearchPage.class));
}
if (showAdmin) {
@@ -197,7 +196,7 @@ public abstract class RootPage extends BasePage {
if (!StringUtils.isEmpty(cachedMessage)) {
error(cachedMessage);
} else if (showAdmin) {
- int pendingProposals = GitBlit.self().getPendingFederationProposals().size();
+ int pendingProposals = app().federation().getPendingFederationProposals().size();
if (pendingProposals == 1) {
info(getString("gb.OneProposalToReview"));
} else if (pendingProposals > 1) {
@@ -229,7 +228,7 @@ public abstract class RootPage extends BasePage {
// remove days back parameter if it is the default value
if (params.containsKey("db")
- && params.getInt("db") == GitBlit.getInteger(Keys.web.activityDuration, 7)) {
+ && params.getInt("db") == app().settings().getInteger(Keys.web.activityDuration, 7)) {
params.remove("db");
}
return params;
@@ -251,9 +250,9 @@ public abstract class RootPage extends BasePage {
session.setUser(user);
// Set Cookie
- if (GitBlit.getBoolean(Keys.web.allowCookieAuthentication, false)) {
+ if (app().settings().getBoolean(Keys.web.allowCookieAuthentication, false)) {
WebResponse response = (WebResponse) getRequestCycle().getResponse();
- GitBlit.self().setCookie(response, user);
+ app().session().setCookie(response, user);
}
if (!session.continueRequest()) {
@@ -274,7 +273,7 @@ public abstract class RootPage extends BasePage {
protected List<RepositoryModel> getRepositoryModels() {
if (repositoryModels.isEmpty()) {
final UserModel user = GitBlitWebSession.get().getUser();
- List<RepositoryModel> repositories = GitBlit.self().getRepositoryModels(user);
+ List<RepositoryModel> repositories = app().repositories().getRepositoryModels(user);
repositoryModels.addAll(repositories);
Collections.sort(repositoryModels);
}
@@ -326,7 +325,7 @@ public abstract class RootPage extends BasePage {
}
// custom filters
- String customFilters = GitBlit.getString(Keys.web.customFilters, null);
+ String customFilters = app().settings().getString(Keys.web.customFilters, null);
if (!StringUtils.isEmpty(customFilters)) {
boolean addedExpression = false;
List<String> expressions = StringUtils.getStringsFromValue(customFilters, "!!!");
@@ -346,8 +345,8 @@ public abstract class RootPage extends BasePage {
protected List<DropDownMenuItem> getTimeFilterItems(PageParameters params) {
// days back choices - additive parameters
- int daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);
- int maxDaysBack = GitBlit.getInteger(Keys.web.activityDurationMaximum, 30);
+ int daysBack = app().settings().getInteger(Keys.web.activityDuration, 7);
+ int maxDaysBack = app().settings().getInteger(Keys.web.activityDurationMaximum, 30);
if (daysBack < 1) {
daysBack = 7;
}
@@ -366,7 +365,7 @@ public abstract class RootPage extends BasePage {
}
List<DropDownMenuItem> items = new ArrayList<DropDownMenuItem>();
- Set<Integer> choicesSet = new TreeSet<Integer>(GitBlit.getIntegers(Keys.web.activityDurationChoices));
+ Set<Integer> choicesSet = new TreeSet<Integer>(app().settings().getIntegers(Keys.web.activityDurationChoices));
if (choicesSet.isEmpty()) {
choicesSet.addAll(Arrays.asList(1, 3, 7, 14, 21, 28));
}
@@ -403,7 +402,7 @@ public abstract class RootPage extends BasePage {
String regex = WicketUtils.getRegEx(params);
String team = WicketUtils.getTeam(params);
int daysBack = params.getInt("db", 0);
- int maxDaysBack = GitBlit.getInteger(Keys.web.activityDurationMaximum, 30);
+ int maxDaysBack = app().settings().getInteger(Keys.web.activityDurationMaximum, 30);
List<RepositoryModel> availableModels = getRepositoryModels();
Set<RepositoryModel> models = new HashSet<RepositoryModel>();
@@ -422,7 +421,7 @@ public abstract class RootPage extends BasePage {
if (!StringUtils.isEmpty(projectName)) {
// try named project
hasParameter = true;
- if (projectName.equalsIgnoreCase(GitBlit.getString(Keys.web.repositoryRootGroupName, "main"))) {
+ if (projectName.equalsIgnoreCase(app().settings().getString(Keys.web.repositoryRootGroupName, "main"))) {
// root project/group
for (RepositoryModel model : availableModels) {
if (model.name.indexOf('/') == -1) {
@@ -472,7 +471,7 @@ public abstract class RootPage extends BasePage {
// need TeamModels first
List<TeamModel> teamModels = new ArrayList<TeamModel>();
for (String name : teams) {
- TeamModel teamModel = GitBlit.self().getTeamModel(name);
+ TeamModel teamModel = app().users().getTeamModel(name);
if (teamModel != null) {
teamModels.add(teamModel);
}
@@ -537,7 +536,7 @@ public abstract class RootPage extends BasePage {
String username = RootPage.this.username.getObject();
char[] password = RootPage.this.password.getObject().toCharArray();
- UserModel user = GitBlit.self().authenticate(username, password);
+ UserModel user = app().session().authenticate(username, password);
if (user == null) {
error(getString("gb.invalidUsernameOrPassword"));
} else if (user.username.equals(Constants.FEDERATION_USER)) {
@@ -563,7 +562,7 @@ public abstract class RootPage extends BasePage {
/**
* Menu for the authenticated user.
*/
- static class UserMenu extends Fragment {
+ class UserMenu extends Fragment {
private static final long serialVersionUID = 1L;
@@ -573,10 +572,10 @@ public abstract class RootPage extends BasePage {
GitBlitWebSession session = GitBlitWebSession.get();
UserModel user = session.getUser();
- boolean editCredentials = GitBlit.self().supportsCredentialChanges(user);
+ boolean editCredentials = app().users().supportsCredentialChanges(user);
boolean standardLogin = session.authenticationType.isStandard();
- if (GitBlit.getBoolean(Keys.web.allowGravatar, true)) {
+ if (app().settings().getBoolean(Keys.web.allowGravatar, true)) {
add(new GravatarImage("username", user.getDisplayName(),
user.emailAddress, "navbarGravatar", 20, false, false));
} else {
diff --git a/src/main/java/com/gitblit/wicket/pages/RootSubPage.java b/src/main/java/com/gitblit/wicket/pages/RootSubPage.java
index e81717a1..62d07a7f 100644
--- a/src/main/java/com/gitblit/wicket/pages/RootSubPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/RootSubPage.java
@@ -24,7 +24,6 @@ import org.apache.wicket.markup.html.basic.Label;
import com.gitblit.Constants.AccessRestrictionType;
import com.gitblit.Constants.AuthorizationControl;
-import com.gitblit.GitBlit;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.UserModel;
import com.gitblit.utils.ModelUtils;
@@ -86,8 +85,8 @@ public abstract class RootSubPage extends RootPage {
}
}
- for (String repo : GitBlit.self().getRepositoryList()) {
- RepositoryModel repositoryModel = GitBlit.self().getRepositoryModel(repo);
+ for (String repo : app().repositories().getRepositoryList()) {
+ RepositoryModel repositoryModel = app().repositories().getRepositoryModel(repo);
if (repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE)
&& repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED)) {
if (user != null &&
diff --git a/src/main/java/com/gitblit/wicket/pages/SendProposalPage.java b/src/main/java/com/gitblit/wicket/pages/SendProposalPage.java
index b1a8c5b6..9ccf1aa2 100644
--- a/src/main/java/com/gitblit/wicket/pages/SendProposalPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/SendProposalPage.java
@@ -27,7 +27,6 @@ import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.CompoundPropertyModel;
import com.gitblit.Constants.FederationProposalResult;
-import com.gitblit.GitBlit;
import com.gitblit.models.FederationProposal;
import com.gitblit.models.RepositoryModel;
import com.gitblit.utils.FederationUtils;
@@ -57,7 +56,7 @@ public class SendProposalPage extends RootSubPage {
destinationUrl = "https://";
// temporary proposal
- FederationProposal proposal = GitBlit.self().createFederationProposal(myUrl, token);
+ FederationProposal proposal = app().federation().createFederationProposal(myUrl, token);
if (proposal == null) {
error(getString("gb.couldNotCreateFederationProposal"), true);
}
@@ -81,7 +80,7 @@ public class SendProposalPage extends RootSubPage {
}
// build new proposal
- FederationProposal proposal = GitBlit.self().createFederationProposal(myUrl, token);
+ FederationProposal proposal = app().federation().createFederationProposal(myUrl, token);
proposal.url = myUrl;
proposal.message = message;
try {
diff --git a/src/main/java/com/gitblit/wicket/pages/SessionPage.java b/src/main/java/com/gitblit/wicket/pages/SessionPage.java
index 5a255ec5..886dd6e6 100644
--- a/src/main/java/com/gitblit/wicket/pages/SessionPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/SessionPage.java
@@ -22,8 +22,9 @@ import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.protocol.http.WebRequest;
import org.apache.wicket.protocol.http.WebResponse;
-import com.gitblit.GitBlit;
+import com.gitblit.Keys;
import com.gitblit.models.UserModel;
+import com.gitblit.wicket.GitBlitWebApp;
import com.gitblit.wicket.GitBlitWebSession;
public abstract class SessionPage extends WebPage {
@@ -38,12 +39,20 @@ public abstract class SessionPage extends WebPage {
login();
}
+ protected String [] getEncodings() {
+ return app().settings().getStrings(Keys.web.blobEncodings).toArray(new String[0]);
+ }
+
+ protected GitBlitWebApp app() {
+ return GitBlitWebApp.get();
+ }
+
private void login() {
GitBlitWebSession session = GitBlitWebSession.get();
if (session.isLoggedIn() && !session.isSessionInvalidated()) {
// already have a session, refresh usermodel to pick up
// any changes to permissions or roles (issue-186)
- UserModel user = GitBlit.self().getUserModel(session.getUser().username);
+ UserModel user = app().users().getUserModel(session.getUser().username);
session.setUser(user);
return;
}
@@ -51,7 +60,7 @@ public abstract class SessionPage extends WebPage {
// try to authenticate by servlet request
HttpServletRequest httpRequest = ((WebRequest) getRequestCycle().getRequest())
.getHttpServletRequest();
- UserModel user = GitBlit.self().authenticate(httpRequest);
+ UserModel user = app().session().authenticate(httpRequest);
// Login the user
if (user != null) {
@@ -61,7 +70,7 @@ public abstract class SessionPage extends WebPage {
// Set Cookie
WebResponse response = (WebResponse) getRequestCycle().getResponse();
- GitBlit.self().setCookie(response, user);
+ app().session().setCookie(response, user);
session.continueRequest();
}
diff --git a/src/main/java/com/gitblit/wicket/pages/SummaryPage.java b/src/main/java/com/gitblit/wicket/pages/SummaryPage.java
index 5604be4e..9129302b 100644
--- a/src/main/java/com/gitblit/wicket/pages/SummaryPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/SummaryPage.java
@@ -40,7 +40,6 @@ import org.wicketstuff.googlecharts.LineStyle;
import org.wicketstuff.googlecharts.MarkerType;
import org.wicketstuff.googlecharts.ShapeMarker;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.Metric;
import com.gitblit.models.RepositoryModel;
@@ -67,11 +66,11 @@ public class SummaryPage extends RepositoryPage {
public SummaryPage(PageParameters params) {
super(params);
- int numberCommits = GitBlit.getInteger(Keys.web.summaryCommitCount, 20);
+ int numberCommits = app().settings().getInteger(Keys.web.summaryCommitCount, 20);
if (numberCommits <= 0) {
numberCommits = 20;
}
- int numberRefs = GitBlit.getInteger(Keys.web.summaryRefsCount, 5);
+ int numberRefs = app().settings().getInteger(Keys.web.summaryRefsCount, 5);
Repository r = getRepository();
final RepositoryModel model = getRepositoryModel();
@@ -82,8 +81,8 @@ public class SummaryPage extends RepositoryPage {
List<Metric> metrics = null;
Metric metricsTotal = null;
- if (!model.skipSummaryMetrics && GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {
- metrics = GitBlit.self().getRepositoryDefaultMetrics(model, r);
+ if (!model.skipSummaryMetrics && app().settings().getBoolean(Keys.web.generateActivityGraph, true)) {
+ metrics = app().repositories().getRepositoryDefaultMetrics(model, r);
metricsTotal = metrics.remove(0);
}
@@ -101,7 +100,7 @@ public class SummaryPage extends RepositoryPage {
@Override
public void populateItem(final Item<String> item) {
String ownername = item.getModelObject();
- UserModel ownerModel = GitBlit.self().getUserModel(ownername);
+ UserModel ownerModel = app().users().getUserModel(ownername);
if (ownerModel != null) {
item.add(new LinkPanel("owner", null, ownerModel.getDisplayName(), UserPage.class,
WicketUtils.newUsernameParameter(ownerModel.username)).setRenderBodyOnly(true));
@@ -138,10 +137,10 @@ public class SummaryPage extends RepositoryPage {
add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs).hideIfEmpty());
add(new BranchesPanel("branchesPanel", getRepositoryModel(), r, numberRefs, false).hideIfEmpty());
- if (GitBlit.getBoolean(Keys.web.summaryShowReadme, false)) {
+ if (app().settings().getBoolean(Keys.web.summaryShowReadme, false)) {
// show a readme on the summary page
RevCommit head = JGitUtils.getCommit(r, null);
- MarkupProcessor processor = new MarkupProcessor(GitBlit.getSettings());
+ MarkupProcessor processor = new MarkupProcessor(app().settings());
MarkupDocument markupDoc = processor.getReadme(r, repositoryName, getBestCommitId(head));
if (markupDoc == null || markupDoc.markup == null) {
add(new Label("readme").setVisible(false));
@@ -169,7 +168,7 @@ public class SummaryPage extends RepositoryPage {
private void insertActivityGraph(List<Metric> metrics) {
if ((metrics != null) && (metrics.size() > 0)
- && GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {
+ && app().settings().getBoolean(Keys.web.generateActivityGraph, true)) {
IChartData data = WicketUtils.getChartData(metrics);
ChartProvider provider = new ChartProvider(new Dimension(290, 100), ChartType.LINE,
diff --git a/src/main/java/com/gitblit/wicket/pages/UserPage.java b/src/main/java/com/gitblit/wicket/pages/UserPage.java
index 4b62e797..1e5ddcf0 100644
--- a/src/main/java/com/gitblit/wicket/pages/UserPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/UserPage.java
@@ -28,7 +28,6 @@ import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
import org.eclipse.jgit.lib.PersonIdent;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.ProjectModel;
import com.gitblit.models.RepositoryModel;
@@ -67,7 +66,7 @@ public class UserPage extends RootPage {
private void setup(PageParameters params) {
setupPage("", "");
// check to see if we should display a login message
- boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, true);
+ boolean authenticateView = app().settings().getBoolean(Keys.web.authenticateViewPages, true);
if (authenticateView && !GitBlitWebSession.get().isLoggedIn()) {
authenticationError("Please login");
return;
@@ -78,7 +77,7 @@ public class UserPage extends RootPage {
throw new GitblitRedirectException(GitBlitWebApp.get().getHomePage());
}
- UserModel user = GitBlit.self().getUserModel(userName);
+ UserModel user = app().users().getUserModel(userName);
if (user == null) {
// construct a temporary user model
user = new UserModel(userName);
@@ -86,7 +85,7 @@ public class UserPage extends RootPage {
String projectName = user.getPersonalPath();
- ProjectModel project = GitBlit.self().getProjectModel(projectName);
+ ProjectModel project = app().projects().getProjectModel(projectName);
if (project == null) {
project = new ProjectModel(projectName);
}
@@ -95,7 +94,7 @@ public class UserPage extends RootPage {
add(new Label("userUsername", user.username));
LinkPanel email = new LinkPanel("userEmail", null, user.emailAddress, "mailto:#");
email.setRenderBodyOnly(true);
- add(email.setVisible(GitBlit.getBoolean(Keys.web.showEmailAddresses, true) && !StringUtils.isEmpty(user.emailAddress)));
+ add(email.setVisible(app().settings().getBoolean(Keys.web.showEmailAddresses, true) && !StringUtils.isEmpty(user.emailAddress)));
PersonIdent person = new PersonIdent(user.getDisplayName(), user.emailAddress == null ? user.getDisplayName() : user.emailAddress);
add(new GravatarImage("gravatar", person, 210));