From 2a81783f291805594d4b97da6830aee94292f8c8 Mon Sep 17 00:00:00 2001 From: James Moger Date: Fri, 17 Aug 2012 15:35:38 -0400 Subject: Eliminated unnecessary repository enumeration (issue 103) --- src/com/gitblit/wicket/pages/RootPage.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/com/gitblit/wicket/pages/RootPage.java b/src/com/gitblit/wicket/pages/RootPage.java index 636ed00e..eaa25425 100644 --- a/src/com/gitblit/wicket/pages/RootPage.java +++ b/src/com/gitblit/wicket/pages/RootPage.java @@ -64,6 +64,7 @@ public abstract class RootPage extends BasePage { IModel username = new Model(""); IModel password = new Model(""); + List repositoryModels = new ArrayList(); public RootPage() { super(); @@ -223,6 +224,15 @@ public abstract class RootPage extends BasePage { } } } + + protected List getRepositoryModels() { + if (repositoryModels.isEmpty()) { + final UserModel user = GitBlitWebSession.get().getUser(); + List repositories = GitBlit.self().getRepositoryModels(user); + repositoryModels.addAll(repositories); + } + return repositoryModels; + } protected void addDropDownMenus(List pages) { @@ -231,7 +241,7 @@ public abstract class RootPage extends BasePage { protected List getRepositoryFilterItems(PageParameters params) { final UserModel user = GitBlitWebSession.get().getUser(); Set filters = new LinkedHashSet(); - List repositories = GitBlit.self().getRepositoryModels(user); + List repositories = getRepositoryModels(); // accessible repositories by federation set Map setMap = new HashMap(); @@ -307,9 +317,8 @@ public abstract class RootPage extends BasePage { } protected List getRepositories(PageParameters params) { - final UserModel user = GitBlitWebSession.get().getUser(); if (params == null) { - return GitBlit.self().getRepositoryModels(user); + return getRepositoryModels(); } boolean hasParameter = false; @@ -319,7 +328,7 @@ public abstract class RootPage extends BasePage { String team = WicketUtils.getTeam(params); int daysBack = params.getInt("db", 0); - List availableModels = GitBlit.self().getRepositoryModels(user); + List availableModels = getRepositoryModels(); Set models = new HashSet(); if (!StringUtils.isEmpty(repositoryName)) { -- cgit v1.2.3