From 5e88265c36b93f63a68bcafb373434a9fbbaa42e Mon Sep 17 00:00:00 2001 From: James Moger Date: Fri, 19 Oct 2012 21:53:13 -0400 Subject: [PATCH] Construct access permissions from already retrieved data --- src/com/gitblit/client/GitblitClient.java | 21 +++++++++++++++---- src/com/gitblit/client/RepositoriesPanel.java | 12 ++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/com/gitblit/client/GitblitClient.java b/src/com/gitblit/client/GitblitClient.java index 9815cbe8..9e31c794 100644 --- a/src/com/gitblit/client/GitblitClient.java +++ b/src/com/gitblit/client/GitblitClient.java @@ -30,6 +30,7 @@ import java.util.TreeSet; import com.gitblit.Constants; import com.gitblit.Constants.AccessRestrictionType; import com.gitblit.Constants.AuthorizationControl; +import com.gitblit.Constants.RegistrantType; import com.gitblit.GitBlitException.ForbiddenException; import com.gitblit.GitBlitException.NotAllowedException; import com.gitblit.GitBlitException.UnauthorizedException; @@ -493,8 +494,14 @@ public class GitblitClient implements Serializable { return usernames; } - public List getUserAccessPermissions(RepositoryModel repository) throws IOException { - return RpcUtils.getRepositoryMemberPermissions(repository, url, account, password); + public List getUserAccessPermissions(RepositoryModel repository) { + List list = new ArrayList(); + for (UserModel user : allUsers) { + if (user.hasRepositoryPermission(repository.name)) { + list.add(new RegistrantAccessPermission(user.username, user.permissions.get(repository.name), RegistrantType.USER)); + } + } + return list; } public boolean setUserAccessPermissions(RepositoryModel repository, List permissions) throws IOException { @@ -524,8 +531,14 @@ public class GitblitClient implements Serializable { return teamnames; } - public List getTeamAccessPermissions(RepositoryModel repository) throws IOException { - return RpcUtils.getRepositoryTeamPermissions(repository, url, account, password); + public List getTeamAccessPermissions(RepositoryModel repository) { + List list = new ArrayList(); + for (TeamModel team : allTeams) { + if (team.hasRepositoryPermission(repository.name)) { + list.add(new RegistrantAccessPermission(team.name, team.permissions.get(repository.name), RegistrantType.TEAM)); + } + } + return list; } public boolean setTeamAccessPermissions(RepositoryModel repository, List permissions) throws IOException { diff --git a/src/com/gitblit/client/RepositoriesPanel.java b/src/com/gitblit/client/RepositoriesPanel.java index 972dda19..28b3959c 100644 --- a/src/com/gitblit/client/RepositoriesPanel.java +++ b/src/com/gitblit/client/RepositoriesPanel.java @@ -453,14 +453,10 @@ public abstract class RepositoriesPanel extends JPanel { repository); dialog.setLocationRelativeTo(RepositoriesPanel.this); List usernames = gitblit.getUsernames(); - try { - List members = gitblit.getUserAccessPermissions(repository); - dialog.setUsers(repository.owner, usernames, members); - dialog.setTeams(gitblit.getTeamnames(), gitblit.getTeamAccessPermissions(repository)); - dialog.setRepositories(gitblit.getRepositories()); - } catch (IOException e) { - // TODO - } + List members = gitblit.getUserAccessPermissions(repository); + dialog.setUsers(repository.owner, usernames, members); + dialog.setTeams(gitblit.getTeamnames(), gitblit.getTeamAccessPermissions(repository)); + dialog.setRepositories(gitblit.getRepositories()); dialog.setFederationSets(gitblit.getFederationSets(), repository.federationSets); List allLocalBranches = new ArrayList(); allLocalBranches.add(Constants.DEFAULT_BRANCH); -- 2.39.5