summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2013-11-16 09:46:55 -0500
committerJames Moger <james.moger@gitblit.com>2013-11-26 16:07:04 -0500
commita7a0b8ea01dca14602fdb49047d987c36461e861 (patch)
treee7db370fc0230c627f54b0e6eef64f1282c591e7 /src
parent718ae7b9f7970ea4475027c8ef91875c0bea5861 (diff)
downloadgitblit-a7a0b8ea01dca14602fdb49047d987c36461e861.tar.gz
gitblit-a7a0b8ea01dca14602fdb49047d987c36461e861.zip
Refactor access to home page class
Change-Id: Ice5706dc0659a44f54e5bf29ca66580e3be22418
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/gitblit/wicket/AuthorizationStrategy.java10
-rw-r--r--src/main/java/com/gitblit/wicket/GitBlitWebApp.java10
-rw-r--r--src/main/java/com/gitblit/wicket/pages/BasePage.java2
-rw-r--r--src/main/java/com/gitblit/wicket/pages/DashboardPage.java2
4 files changed, 13 insertions, 11 deletions
diff --git a/src/main/java/com/gitblit/wicket/AuthorizationStrategy.java b/src/main/java/com/gitblit/wicket/AuthorizationStrategy.java
index e3774d82..a00e2e2f 100644
--- a/src/main/java/com/gitblit/wicket/AuthorizationStrategy.java
+++ b/src/main/java/com/gitblit/wicket/AuthorizationStrategy.java
@@ -19,6 +19,7 @@ import org.apache.wicket.Component;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.authorization.IUnauthorizedComponentInstantiationListener;
import org.apache.wicket.authorization.strategies.page.AbstractPageAuthorizationStrategy;
+import org.apache.wicket.markup.html.WebPage;
import com.gitblit.GitBlit;
import com.gitblit.Keys;
@@ -28,13 +29,16 @@ import com.gitblit.wicket.pages.BasePage;
public class AuthorizationStrategy extends AbstractPageAuthorizationStrategy implements
IUnauthorizedComponentInstantiationListener {
- public AuthorizationStrategy() {
+ Class<? extends WebPage> homepageClass;
+
+ public AuthorizationStrategy(Class<? extends WebPage> homepageClass) {
+ this.homepageClass = homepageClass;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected boolean isPageAuthorized(Class pageClass) {
- if (GitBlitWebApp.HOME_PAGE_CLASS.equals(pageClass)) {
+ if (homepageClass.equals(pageClass)) {
// allow all requests to get to the HomePage with its inline
// authentication form
return true;
@@ -79,7 +83,7 @@ public class AuthorizationStrategy extends AbstractPageAuthorizationStrategy imp
public void onUnauthorizedInstantiation(Component component) {
if (component instanceof BasePage) {
- throw new RestartResponseException(GitBlitWebApp.HOME_PAGE_CLASS);
+ throw new RestartResponseException(homepageClass);
}
}
}
diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp.java b/src/main/java/com/gitblit/wicket/GitBlitWebApp.java
index 70aa1a6a..8cbda461 100644
--- a/src/main/java/com/gitblit/wicket/GitBlitWebApp.java
+++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp.java
@@ -20,7 +20,6 @@ import java.util.Locale;
import java.util.Map;
import org.apache.wicket.Application;
-import org.apache.wicket.Page;
import org.apache.wicket.Request;
import org.apache.wicket.Response;
import org.apache.wicket.Session;
@@ -31,7 +30,6 @@ import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.pages.ActivityPage;
-import com.gitblit.wicket.pages.BasePage;
import com.gitblit.wicket.pages.BlamePage;
import com.gitblit.wicket.pages.BlobDiffPage;
import com.gitblit.wicket.pages.BlobPage;
@@ -69,7 +67,7 @@ import com.gitblit.wicket.pages.UsersPage;
public class GitBlitWebApp extends WebApplication {
- public final static Class<? extends BasePage> HOME_PAGE_CLASS = MyDashboardPage.class;
+ private final Class<? extends WebPage> homePageClass = MyDashboardPage.class;
private final Map<String, CacheControl> cacheablePages = new HashMap<String, CacheControl>();
@@ -81,7 +79,7 @@ public class GitBlitWebApp extends WebApplication {
boolean useAuthentication = GitBlit.getBoolean(Keys.web.authenticateViewPages, false)
|| GitBlit.getBoolean(Keys.web.authenticateAdminPages, false);
if (useAuthentication) {
- AuthorizationStrategy authStrategy = new AuthorizationStrategy();
+ AuthorizationStrategy authStrategy = new AuthorizationStrategy(homePageClass);
getSecuritySettings().setAuthorizationStrategy(authStrategy);
getSecuritySettings().setUnauthorizedComponentInstantiationListener(authStrategy);
}
@@ -158,8 +156,8 @@ public class GitBlitWebApp extends WebApplication {
}
@Override
- public Class<? extends Page> getHomePage() {
- return HOME_PAGE_CLASS;
+ public Class<? extends WebPage> getHomePage() {
+ return homePageClass;
}
public boolean isCacheablePage(String mountPoint) {
diff --git a/src/main/java/com/gitblit/wicket/pages/BasePage.java b/src/main/java/com/gitblit/wicket/pages/BasePage.java
index ec69a719..9bae3783 100644
--- a/src/main/java/com/gitblit/wicket/pages/BasePage.java
+++ b/src/main/java/com/gitblit/wicket/pages/BasePage.java
@@ -212,7 +212,7 @@ public abstract class BasePage extends SessionPage {
add(new Label("title", siteName));
}
- String rootLinkUrl = GitBlit.getString(Keys.web.rootLink, urlFor(GitBlitWebApp.HOME_PAGE_CLASS, null).toString());
+ String rootLinkUrl = GitBlit.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));
add(rootLink);
diff --git a/src/main/java/com/gitblit/wicket/pages/DashboardPage.java b/src/main/java/com/gitblit/wicket/pages/DashboardPage.java
index 5c72b8bd..46adcffe 100644
--- a/src/main/java/com/gitblit/wicket/pages/DashboardPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/DashboardPage.java
@@ -146,7 +146,7 @@ public abstract class DashboardPage extends RootPage {
PageParameters params = getPageParameters();
DropDownMenuRegistration menu = new DropDownMenuRegistration("gb.filters",
- GitBlitWebApp.HOME_PAGE_CLASS);
+ GitBlitWebApp.get().getHomePage());
// preserve repository filter option on time choices
menu.menuItems.addAll(getTimeFilterItems(params));