]> source.dussan.org Git - gitblit.git/commitdiff
Construct access permissions from already retrieved data
authorJames Moger <james.moger@gitblit.com>
Sat, 20 Oct 2012 01:53:13 +0000 (21:53 -0400)
committerJames Moger <james.moger@gitblit.com>
Sat, 20 Oct 2012 02:47:34 +0000 (22:47 -0400)
src/com/gitblit/client/GitblitClient.java
src/com/gitblit/client/RepositoriesPanel.java

index 9815cbe88025fe3297d6ddb366ddefd09acd3a21..9e31c794f6419c818f079aedb006e959e404598c 100644 (file)
@@ -30,6 +30,7 @@ import java.util.TreeSet;
 import com.gitblit.Constants;\r
 import com.gitblit.Constants.AccessRestrictionType;\r
 import com.gitblit.Constants.AuthorizationControl;\r
+import com.gitblit.Constants.RegistrantType;\r
 import com.gitblit.GitBlitException.ForbiddenException;\r
 import com.gitblit.GitBlitException.NotAllowedException;\r
 import com.gitblit.GitBlitException.UnauthorizedException;\r
@@ -493,8 +494,14 @@ public class GitblitClient implements Serializable {
                return usernames;\r
        }\r
        \r
-       public List<RegistrantAccessPermission> getUserAccessPermissions(RepositoryModel repository) throws IOException {\r
-               return RpcUtils.getRepositoryMemberPermissions(repository, url, account, password);\r
+       public List<RegistrantAccessPermission> getUserAccessPermissions(RepositoryModel repository) {\r
+               List<RegistrantAccessPermission> list = new ArrayList<RegistrantAccessPermission>();\r
+               for (UserModel user : allUsers) {\r
+                       if (user.hasRepositoryPermission(repository.name)) {\r
+                               list.add(new RegistrantAccessPermission(user.username, user.permissions.get(repository.name), RegistrantType.USER));\r
+                       }\r
+               }\r
+               return list;\r
        }\r
 \r
        public boolean setUserAccessPermissions(RepositoryModel repository, List<RegistrantAccessPermission> permissions) throws IOException {\r
@@ -524,8 +531,14 @@ public class GitblitClient implements Serializable {
                return teamnames;\r
        }\r
        \r
-       public List<RegistrantAccessPermission> getTeamAccessPermissions(RepositoryModel repository) throws IOException {\r
-               return RpcUtils.getRepositoryTeamPermissions(repository, url, account, password);\r
+       public List<RegistrantAccessPermission> getTeamAccessPermissions(RepositoryModel repository) {\r
+               List<RegistrantAccessPermission> list = new ArrayList<RegistrantAccessPermission>();\r
+               for (TeamModel team : allTeams) {\r
+                       if (team.hasRepositoryPermission(repository.name)) {\r
+                               list.add(new RegistrantAccessPermission(team.name, team.permissions.get(repository.name), RegistrantType.TEAM));\r
+                       }\r
+               }\r
+               return list;\r
        }\r
 \r
        public boolean setTeamAccessPermissions(RepositoryModel repository, List<RegistrantAccessPermission> permissions) throws IOException {\r
index 972dda19cf3f34e44ec2a437b21abfe4cf910550..28b3959c8910cf03c9284235d0b62f35b2db1da4 100644 (file)
@@ -453,14 +453,10 @@ public abstract class RepositoriesPanel extends JPanel {
                                repository);\r
                dialog.setLocationRelativeTo(RepositoriesPanel.this);\r
                List<String> usernames = gitblit.getUsernames();\r
-               try {\r
-                       List<RegistrantAccessPermission> members = gitblit.getUserAccessPermissions(repository);\r
-                       dialog.setUsers(repository.owner, usernames, members);\r
-                       dialog.setTeams(gitblit.getTeamnames(), gitblit.getTeamAccessPermissions(repository));\r
-                       dialog.setRepositories(gitblit.getRepositories());\r
-               } catch (IOException e) {\r
-                       //  TODO\r
-               }\r
+               List<RegistrantAccessPermission> members = gitblit.getUserAccessPermissions(repository);\r
+               dialog.setUsers(repository.owner, usernames, members);\r
+               dialog.setTeams(gitblit.getTeamnames(), gitblit.getTeamAccessPermissions(repository));\r
+               dialog.setRepositories(gitblit.getRepositories());\r
                dialog.setFederationSets(gitblit.getFederationSets(), repository.federationSets);\r
                List<String> allLocalBranches = new ArrayList<String>();\r
                allLocalBranches.add(Constants.DEFAULT_BRANCH);\r