]> source.dussan.org Git - gitblit.git/commitdiff
Stabilizing and polishing permissions ui. Still in-progress.
authorJames Moger <james.moger@gitblit.com>
Tue, 30 Oct 2012 03:22:54 +0000 (23:22 -0400)
committerJames Moger <james.moger@gitblit.com>
Tue, 30 Oct 2012 03:22:54 +0000 (23:22 -0400)
23 files changed:
resources/gitblit.css
src/com/gitblit/Constants.java
src/com/gitblit/GitBlit.java
src/com/gitblit/client/EditRepositoryDialog.java
src/com/gitblit/client/EditTeamDialog.java
src/com/gitblit/client/EditUserDialog.java
src/com/gitblit/client/GitblitClient.java
src/com/gitblit/client/RegistrantPermissionsPanel.java
src/com/gitblit/client/RegistrantPermissionsTableModel.java
src/com/gitblit/client/UsersPanel.java
src/com/gitblit/models/RegistrantAccessPermission.java
src/com/gitblit/models/TeamModel.java
src/com/gitblit/models/UserModel.java
src/com/gitblit/wicket/GitBlitWebApp.properties
src/com/gitblit/wicket/pages/BasePage.java
src/com/gitblit/wicket/pages/EditRepositoryPage.html
src/com/gitblit/wicket/pages/EditRepositoryPage.java
src/com/gitblit/wicket/pages/EditTeamPage.java
src/com/gitblit/wicket/pages/EditUserPage.java
src/com/gitblit/wicket/pages/RootSubPage.java
src/com/gitblit/wicket/panels/RegistrantPermissionsPanel.html
src/com/gitblit/wicket/panels/RegistrantPermissionsPanel.java
tests/com/gitblit/tests/RpcTests.java

index 5c2d92a8b5f4b57165cb7fc58ed3dc5174768ad5..e5363c852c980142ce0a69bc21c78ee274acb15f 100644 (file)
@@ -188,6 +188,12 @@ div.even {
        vertical-align: middle;\r
 }\r
 \r
+span.authorizationControl label {\r
+       display: inline;\r
+       color: #777;\r
+       padding:5px 0px 5px 10px;       \r
+}\r
+\r
 div.page_footer {\r
        clear: both;\r
        height: 17px;\r
index f74317eae72e39913b3dda6bad2a28b5162bc804..e7812ee35cf7bc6f904e279bbca2e465c97e79a8 100644 (file)
@@ -386,6 +386,10 @@ public class Constants {
                REPOSITORY, USER, TEAM;\r
        }\r
        \r
+       public static enum PermissionType {\r
+               EXPLICIT, OWNER, REGEX;\r
+       }\r
+       \r
        public static enum GCStatus {\r
                READY, COLLECTING;\r
                \r
index 402f600d7fa2b917782298ba2d0bd65ae6386503..6e587caa1c4d1c8d81198feca7c5146a29c0ef8e 100644 (file)
@@ -79,6 +79,7 @@ import com.gitblit.Constants.AuthorizationControl;
 import com.gitblit.Constants.FederationRequest;\r
 import com.gitblit.Constants.FederationStrategy;\r
 import com.gitblit.Constants.FederationToken;\r
+import com.gitblit.Constants.PermissionType;\r
 import com.gitblit.Constants.RegistrantType;\r
 import com.gitblit.models.FederationModel;\r
 import com.gitblit.models.FederationProposal;\r
@@ -670,14 +671,35 @@ public class GitBlit implements ServletContextListener {
         * @return a list of User-AccessPermission tuples\r
         */\r
        public List<RegistrantAccessPermission> getUserAccessPermissions(RepositoryModel repository) {\r
-               List<RegistrantAccessPermission> permissions = new ArrayList<RegistrantAccessPermission>();\r
+               Set<RegistrantAccessPermission> permissions = new LinkedHashSet<RegistrantAccessPermission>();\r
+               if (!StringUtils.isEmpty(repository.owner)) {\r
+                       UserModel owner = userService.getUserModel(repository.owner);\r
+                       if (owner != null) {\r
+                               permissions.add(new RegistrantAccessPermission(owner.username, AccessPermission.REWIND, PermissionType.OWNER, RegistrantType.USER, false));\r
+                       }\r
+               }\r
+               if (repository.isPersonalRepository()) {\r
+                       UserModel owner = userService.getUserModel(repository.projectPath.substring(1));\r
+                       if (owner != null) {\r
+                               permissions.add(new RegistrantAccessPermission(owner.username, AccessPermission.REWIND, PermissionType.OWNER, RegistrantType.USER, false));\r
+                       }\r
+               }\r
                for (String user : userService.getUsernamesForRepositoryRole(repository.name)) {\r
                        UserModel model = userService.getUserModel(user);\r
                        AccessPermission ap = model.getRepositoryPermission(repository);\r
-                       boolean isExplicit = model.hasExplicitRepositoryPermission(repository.name);\r
-                       permissions.add(new RegistrantAccessPermission(user, ap, isExplicit, RegistrantType.USER));\r
-               }\r
-               return permissions;\r
+                       PermissionType pType = PermissionType.REGEX;\r
+                       boolean editable = false;\r
+                       if (repository.isOwner(model.username)) {\r
+                               pType = PermissionType.OWNER;\r
+                       } else if (repository.isUsersPersonalRepository(model.username)) {\r
+                               pType = PermissionType.OWNER;\r
+                       } else if (model.hasExplicitRepositoryPermission(repository.name)) {\r
+                               pType = PermissionType.EXPLICIT;\r
+                               editable = true;\r
+                       }                       \r
+                       permissions.add(new RegistrantAccessPermission(user, ap, pType, RegistrantType.USER, editable));\r
+               }\r
+               return new ArrayList<RegistrantAccessPermission>(permissions);\r
        }\r
        \r
        /**\r
@@ -690,8 +712,8 @@ public class GitBlit implements ServletContextListener {
        public boolean setUserAccessPermissions(RepositoryModel repository, Collection<RegistrantAccessPermission> permissions) {\r
                List<UserModel> users = new ArrayList<UserModel>();\r
                for (RegistrantAccessPermission up : permissions) {\r
-                       if (up.isExplicit) {\r
-                               // only set explicitly defined permissions\r
+                       if (up.isEditable) {\r
+                               // only set editable defined permissions\r
                                UserModel user = userService.getUserModel(up.registrant);\r
                                user.setRepositoryPermission(repository.name, up.permission);\r
                                users.add(user);\r
@@ -811,8 +833,13 @@ public class GitBlit implements ServletContextListener {
                for (String team : userService.getTeamnamesForRepositoryRole(repository.name)) {\r
                        TeamModel model = userService.getTeamModel(team);\r
                        AccessPermission ap = model.getRepositoryPermission(repository);\r
-                       boolean isExplicit = model.hasExplicitRepositoryPermission(repository.name);\r
-                       permissions.add(new RegistrantAccessPermission(team, ap, isExplicit, RegistrantType.TEAM));\r
+                       PermissionType pType = PermissionType.REGEX;\r
+                       boolean editable = false;\r
+                       if (model.hasExplicitRepositoryPermission(repository.name)) {\r
+                               pType = PermissionType.EXPLICIT;\r
+                               editable = true;\r
+                       }\r
+                       permissions.add(new RegistrantAccessPermission(team, ap, pType, RegistrantType.TEAM, editable));\r
                }\r
                return permissions;\r
        }\r
@@ -827,7 +854,7 @@ public class GitBlit implements ServletContextListener {
        public boolean setTeamAccessPermissions(RepositoryModel repository, Collection<RegistrantAccessPermission> permissions) {\r
                List<TeamModel> teams = new ArrayList<TeamModel>();\r
                for (RegistrantAccessPermission tp : permissions) {\r
-                       if (tp.isExplicit) {\r
+                       if (tp.isEditable) {\r
                                // only set explicitly defined access permissions\r
                                TeamModel team = userService.getTeamModel(tp.registrant);\r
                                team.setRepositoryPermission(repository.name, tp.permission);\r
@@ -1870,7 +1897,9 @@ public class GitBlit implements ServletContextListener {
                config.setBoolean(Constants.CONFIG_GITBLIT, null, "isFederated", repository.isFederated);\r
                config.setString(Constants.CONFIG_GITBLIT, null, "gcThreshold", repository.gcThreshold);\r
                config.setString(Constants.CONFIG_GITBLIT, null, "gcPeriod", repository.gcPeriod);\r
-               config.setString(Constants.CONFIG_GITBLIT, null, "lastGC", new SimpleDateFormat(Constants.ISO8601).format(repository.lastGC));\r
+               if (repository.lastGC != null) {\r
+                       config.setString(Constants.CONFIG_GITBLIT, null, "lastGC", new SimpleDateFormat(Constants.ISO8601).format(repository.lastGC));\r
+               }\r
 \r
                updateList(config, "federationSets", repository.federationSets);\r
                updateList(config, "preReceiveScript", repository.preReceiveScripts);\r
index 0adf8a8076eeacde9b494a6f1ccae003f9475c96..06621c21b823f6780034ebf558b597c7ae8a4192 100644 (file)
@@ -24,6 +24,8 @@ import java.awt.GridLayout;
 import java.awt.Insets;\r
 import java.awt.event.ActionEvent;\r
 import java.awt.event.ActionListener;\r
+import java.awt.event.ItemEvent;\r
+import java.awt.event.ItemListener;\r
 import java.awt.event.KeyEvent;\r
 import java.text.MessageFormat;\r
 import java.util.ArrayList;\r
@@ -37,6 +39,7 @@ import java.util.Set;
 import javax.swing.BoxLayout;\r
 import javax.swing.ButtonGroup;\r
 import javax.swing.DefaultComboBoxModel;\r
+import javax.swing.DefaultListCellRenderer;\r
 import javax.swing.ImageIcon;\r
 import javax.swing.JButton;\r
 import javax.swing.JCheckBox;\r
@@ -59,6 +62,7 @@ import javax.swing.ScrollPaneConstants;
 import com.gitblit.Constants.AccessRestrictionType;\r
 import com.gitblit.Constants.AuthorizationControl;\r
 import com.gitblit.Constants.FederationStrategy;\r
+import com.gitblit.Constants.RegistrantType;\r
 import com.gitblit.models.RegistrantAccessPermission;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.utils.ArrayUtils;\r
@@ -218,13 +222,41 @@ public class EditRepositoryDialog extends JDialog {
                accessRestriction = new JComboBox(AccessRestrictionType.values());\r
                accessRestriction.setRenderer(new AccessRestrictionRenderer());\r
                accessRestriction.setSelectedItem(anRepository.accessRestriction);\r
+               accessRestriction.addItemListener(new ItemListener() {\r
+                       @Override\r
+                       public void itemStateChanged(ItemEvent e) {\r
+                               if (e.getStateChange() == ItemEvent.SELECTED) {\r
+                                       AccessRestrictionType art = (AccessRestrictionType) accessRestriction.getSelectedItem();\r
+                                       EditRepositoryDialog.this.setupAccessPermissions(art);\r
+                               }\r
+                       }\r
+               });\r
                \r
                boolean authenticated = anRepository.authorizationControl != null \r
                                && AuthorizationControl.AUTHENTICATED.equals(anRepository.authorizationControl);\r
                allowAuthenticated = new JRadioButton(Translation.get("gb.allowAuthenticatedDescription"));\r
                allowAuthenticated.setSelected(authenticated);\r
+               allowAuthenticated.addItemListener(new ItemListener() {\r
+                       @Override\r
+                       public void itemStateChanged(ItemEvent e) {\r
+                               if (e.getStateChange() == ItemEvent.SELECTED) {\r
+                                       usersPalette.setEnabled(false);\r
+                                       teamsPalette.setEnabled(false);\r
+                               }\r
+                       }\r
+               });\r
+               \r
                allowNamed = new JRadioButton(Translation.get("gb.allowNamedDescription"));\r
                allowNamed.setSelected(!authenticated);\r
+               allowNamed.addItemListener(new ItemListener() {\r
+                       @Override\r
+                       public void itemStateChanged(ItemEvent e) {\r
+                               if (e.getStateChange() == ItemEvent.SELECTED) {\r
+                                       usersPalette.setEnabled(true);\r
+                                       teamsPalette.setEnabled(true);\r
+                               }\r
+                       }\r
+               });\r
                \r
                ButtonGroup group = new ButtonGroup();\r
                group.add(allowAuthenticated);\r
@@ -281,7 +313,7 @@ public class EditRepositoryDialog extends JDialog {
                clonePushPanel\r
                .add(newFieldPanel(Translation.get("gb.verifyCommitter"), verifyCommitter));\r
 \r
-               usersPalette = new RegistrantPermissionsPanel();\r
+               usersPalette = new RegistrantPermissionsPanel(RegistrantType.USER);\r
                JPanel northAccessPanel = new JPanel(new BorderLayout(5, 5));\r
                northAccessPanel.add(newFieldPanel(Translation.get("gb.accessRestriction"),\r
                                accessRestriction), BorderLayout.NORTH);\r
@@ -294,7 +326,7 @@ public class EditRepositoryDialog extends JDialog {
                accessPanel.add(newFieldPanel(Translation.get("gb.userPermissions"),\r
                                                usersPalette), BorderLayout.CENTER);\r
 \r
-               teamsPalette = new RegistrantPermissionsPanel();\r
+               teamsPalette = new RegistrantPermissionsPanel(RegistrantType.TEAM);\r
                JPanel teamsPanel = new JPanel(new BorderLayout(5, 5));\r
                teamsPanel.add(\r
                                newFieldPanel(Translation.get("gb.teamPermissions"),\r
@@ -349,6 +381,8 @@ public class EditRepositoryDialog extends JDialog {
                panel.addTab(Translation.get("gb.customFields"), customFieldsScrollPane);\r
                \r
 \r
+               setupAccessPermissions(anRepository.accessRestriction);\r
+\r
                JButton createButton = new JButton(Translation.get("gb.save"));\r
                createButton.addActionListener(new ActionListener() {\r
                        public void actionPerformed(ActionEvent event) {\r
@@ -403,6 +437,25 @@ public class EditRepositoryDialog extends JDialog {
                panel.add(comp);\r
                return panel;\r
        }\r
+       \r
+       private void setupAccessPermissions(AccessRestrictionType art) {\r
+               if (AccessRestrictionType.NONE.equals(art)) {\r
+                       usersPalette.setEnabled(false);\r
+                       teamsPalette.setEnabled(false);\r
+                       \r
+                       allowAuthenticated.setEnabled(false);\r
+                       allowNamed.setEnabled(false);\r
+               } else {\r
+                       allowAuthenticated.setEnabled(true);\r
+                       allowNamed.setEnabled(true);\r
+                       \r
+                       if (allowNamed.isSelected()) {\r
+                               usersPalette.setEnabled(true);\r
+                               teamsPalette.setEnabled(true);\r
+                       }\r
+               }\r
+\r
+       }\r
 \r
        private boolean validateFields() {\r
                String rname = nameField.getText();\r
@@ -538,6 +591,7 @@ public class EditRepositoryDialog extends JDialog {
        \r
        public void setAccessRestriction(AccessRestrictionType restriction) {\r
                this.accessRestriction.setSelectedItem(restriction);\r
+               setupAccessPermissions(restriction);\r
        }\r
 \r
        public void setAuthorizationControl(AuthorizationControl authorization) {\r
@@ -659,14 +713,15 @@ public class EditRepositoryDialog extends JDialog {
         * restriction.\r
         * \r
         */\r
-       private class AccessRestrictionRenderer extends JLabel implements\r
-                       ListCellRenderer {\r
+       private class AccessRestrictionRenderer extends DefaultListCellRenderer {\r
 \r
                private static final long serialVersionUID = 1L;\r
 \r
                @Override\r
                public Component getListCellRendererComponent(JList list, Object value,\r
                                int index, boolean isSelected, boolean cellHasFocus) {\r
+                       super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);\r
+                       \r
                        if (value instanceof AccessRestrictionType) {\r
                                AccessRestrictionType restriction = (AccessRestrictionType) value;\r
                                switch (restriction) {\r
index 4350310e5e0d42e968637dcc2e086bc036541fb5..4d7af261c79d69ad432d4e1887178f0b89ab0b3a 100644 (file)
@@ -45,11 +45,12 @@ import javax.swing.JTextField;
 import javax.swing.KeyStroke;\r
 \r
 import com.gitblit.Constants.AccessRestrictionType;\r
+import com.gitblit.Constants.AuthorizationControl;\r
+import com.gitblit.Constants.RegistrantType;\r
 import com.gitblit.models.RegistrantAccessPermission;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.ServerSettings;\r
 import com.gitblit.models.TeamModel;\r
-import com.gitblit.utils.ArrayUtils;\r
 import com.gitblit.utils.StringUtils;\r
 \r
 public class EditTeamDialog extends JDialog {\r
@@ -140,7 +141,7 @@ public class EditTeamDialog extends JDialog {
                fieldsPanel.add(newFieldPanel(Translation.get("gb.mailingLists"), mailingListsField));\r
 \r
                final Insets _insets = new Insets(5, 5, 5, 5);\r
-               repositoryPalette = new RegistrantPermissionsPanel();\r
+               repositoryPalette = new RegistrantPermissionsPanel(RegistrantType.REPOSITORY);\r
                userPalette = new JPalette<String>();\r
                userPalette.setEnabled(settings.supportsTeamMembershipChanges);\r
                \r
@@ -311,9 +312,10 @@ public class EditTeamDialog extends JDialog {
        public void setRepositories(List<RepositoryModel> repositories, List<RegistrantAccessPermission> permissions) {\r
                List<String> restricted = new ArrayList<String>();\r
                for (RepositoryModel repo : repositories) {\r
-                       if (repo.accessRestriction.exceeds(AccessRestrictionType.NONE)) {\r
+                       if (repo.accessRestriction.exceeds(AccessRestrictionType.NONE)\r
+                                       && repo.authorizationControl.equals(AuthorizationControl.NAMED)) {\r
                                restricted.add(repo.name);\r
-                       }\r
+                       }                               \r
                }\r
                StringUtils.sortRepositorynames(restricted);\r
                \r
index e096693391349b1423095599e7de6aa2b615a4ad..070926ddf53a7d357d3a66661bcbebd2494369bb 100644 (file)
@@ -46,6 +46,8 @@ import javax.swing.JTextField;
 import javax.swing.KeyStroke;\r
 \r
 import com.gitblit.Constants.AccessRestrictionType;\r
+import com.gitblit.Constants.AuthorizationControl;\r
+import com.gitblit.Constants.RegistrantType;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.RegistrantAccessPermission;\r
 import com.gitblit.models.RepositoryModel;\r
@@ -158,7 +160,7 @@ public class EditUserDialog extends JDialog {
                                notFederatedCheckbox));\r
 \r
                final Insets _insets = new Insets(5, 5, 5, 5);\r
-               repositoryPalette = new RegistrantPermissionsPanel();\r
+               repositoryPalette = new RegistrantPermissionsPanel(RegistrantType.REPOSITORY);\r
                teamsPalette = new JPalette<TeamModel>();\r
                teamsPalette.setEnabled(settings.supportsTeamMembershipChanges);\r
 \r
@@ -343,8 +345,12 @@ public class EditUserDialog extends JDialog {
        public void setRepositories(List<RepositoryModel> repositories, List<RegistrantAccessPermission> permissions) {\r
                List<String> restricted = new ArrayList<String>();\r
                for (RepositoryModel repo : repositories) {\r
-                       if (repo.accessRestriction.exceeds(AccessRestrictionType.NONE)) {\r
-                               restricted.add(repo.name);\r
+                       // exclude Owner or personal repositories\r
+                       if (!repo.isOwner(username) && !repo.isUsersPersonalRepository(username)) {\r
+                               if (repo.accessRestriction.exceeds(AccessRestrictionType.NONE)\r
+                                               && repo.authorizationControl.equals(AuthorizationControl.NAMED)) {\r
+                                       restricted.add(repo.name);\r
+                               }                               \r
                        }\r
                }\r
                StringUtils.sortRepositorynames(restricted);\r
@@ -356,15 +362,15 @@ public class EditUserDialog extends JDialog {
                list.add("[^~].*");\r
                String lastProject = null;\r
                for (String repo : restricted) {\r
-                       String projectPath = StringUtils.getFirstPathElement(repo);\r
+                       String projectPath = StringUtils.getFirstPathElement(repo).toLowerCase();\r
                        if (lastProject == null || !lastProject.equalsIgnoreCase(projectPath)) {\r
                                lastProject = projectPath;\r
                                if (!StringUtils.isEmpty(projectPath)) {\r
                                        // regex for all repositories within a project\r
                                        list.add(projectPath + "/.*");\r
                                }\r
-                               list.add(repo);\r
                        }\r
+                       list.add(repo);\r
                }\r
 \r
                // remove repositories for which user already has a permission\r
@@ -372,7 +378,7 @@ public class EditUserDialog extends JDialog {
                        permissions = new ArrayList<RegistrantAccessPermission>();\r
                } else {\r
                        for (RegistrantAccessPermission rp : permissions) {\r
-                               list.remove(rp.registrant);\r
+                               list.remove(rp.registrant.toLowerCase());\r
                        }\r
                }\r
                repositoryPalette.setObjects(list, permissions);\r
index 4620fefa6c9e97a9d79127cea413aadd81cd32cf..b7047d7fbfaac6a9e7d7586436999dad9731be3d 100644 (file)
@@ -31,6 +31,7 @@ import com.gitblit.Constants;
 import com.gitblit.Constants.AccessPermission;\r
 import com.gitblit.Constants.AccessRestrictionType;\r
 import com.gitblit.Constants.AuthorizationControl;\r
+import com.gitblit.Constants.PermissionType;\r
 import com.gitblit.Constants.RegistrantType;\r
 import com.gitblit.GitBlitException.ForbiddenException;\r
 import com.gitblit.GitBlitException.NotAllowedException;\r
@@ -340,6 +341,7 @@ public class GitblitClient implements Serializable {
                List<UserModel> users = RpcUtils.getUsers(url, account, password);\r
                allUsers.clear();\r
                allUsers.addAll(users);\r
+               Collections.sort(users);\r
                return allUsers;\r
        }\r
 \r
@@ -347,6 +349,7 @@ public class GitblitClient implements Serializable {
                List<TeamModel> teams = RpcUtils.getTeams(url, account, password);\r
                allTeams.clear();\r
                allTeams.addAll(teams);\r
+               Collections.sort(teams);\r
                return allTeams;\r
        }\r
 \r
@@ -475,6 +478,15 @@ public class GitblitClient implements Serializable {
        public List<UserModel> getUsers() {\r
                return allUsers;\r
        }\r
+       \r
+       public UserModel getUser(String username) {\r
+               for (UserModel user : getUsers()) {\r
+                       if (user.username.equalsIgnoreCase(username)) {\r
+                               return user;\r
+                       }\r
+               }\r
+               return null;\r
+       }\r
 \r
        public List<String> getUsernames() {\r
                List<String> usernames = new ArrayList<String>();\r
@@ -496,15 +508,38 @@ public class GitblitClient implements Serializable {
        }\r
        \r
        public List<RegistrantAccessPermission> getUserAccessPermissions(RepositoryModel repository) {\r
-               List<RegistrantAccessPermission> list = new ArrayList<RegistrantAccessPermission>();\r
-               for (UserModel user : allUsers) {\r
+               Set<RegistrantAccessPermission> list = new LinkedHashSet<RegistrantAccessPermission>();\r
+               if (!StringUtils.isEmpty(repository.owner)) {\r
+                       UserModel owner = getUser(repository.owner);\r
+                       if (owner != null) {\r
+                               list.add(new RegistrantAccessPermission(owner.username, AccessPermission.REWIND, PermissionType.OWNER, RegistrantType.USER, false));\r
+                       }\r
+               }\r
+               if (repository.isPersonalRepository()) {\r
+                       UserModel owner = getUser(repository.projectPath.substring(1));\r
+                       if (owner != null) {\r
+                               list.add(new RegistrantAccessPermission(owner.username, AccessPermission.REWIND, PermissionType.OWNER, RegistrantType.USER, false));\r
+                       }\r
+               }\r
+               for (UserModel user : getUsers()) {\r
                        if (user.hasRepositoryPermission(repository.name)) {\r
                                AccessPermission ap = user.getRepositoryPermission(repository);\r
-                               boolean isExplicit = user.hasExplicitRepositoryPermission(repository.name);\r
-                               list.add(new RegistrantAccessPermission(user.username, ap, isExplicit, RegistrantType.USER));\r
+                               PermissionType pType = PermissionType.REGEX;\r
+                               boolean editable = false;\r
+                               if (repository.isOwner(user.username)) {\r
+                                       pType = PermissionType.OWNER;\r
+                               } else if (repository.isUsersPersonalRepository(user.username)) {\r
+                                       pType = PermissionType.OWNER;\r
+                               } else if (user.hasExplicitRepositoryPermission(repository.name)) {\r
+                                       pType = PermissionType.EXPLICIT;\r
+                                       editable = true;\r
+                               }                       \r
+                               list.add(new RegistrantAccessPermission(user.username, ap, pType, RegistrantType.USER, editable));\r
                        }\r
                }\r
-               return list;\r
+               List<RegistrantAccessPermission> raps = new ArrayList<RegistrantAccessPermission>(list);\r
+               Collections.sort(raps);\r
+               return raps;\r
        }\r
 \r
        public boolean setUserAccessPermissions(RepositoryModel repository, List<RegistrantAccessPermission> permissions) throws IOException {\r
@@ -539,10 +574,16 @@ public class GitblitClient implements Serializable {
                for (TeamModel team : allTeams) {\r
                        if (team.hasRepositoryPermission(repository.name)) {\r
                                AccessPermission ap = team.getRepositoryPermission(repository);\r
-                               boolean isExplicit = team.hasExplicitRepositoryPermission(repository.name);\r
-                               list.add(new RegistrantAccessPermission(team.name, ap, isExplicit, RegistrantType.TEAM));\r
+                               PermissionType pType = PermissionType.REGEX;\r
+                               boolean editable = false;\r
+                               if (team.hasExplicitRepositoryPermission(repository.name)) {\r
+                                       pType = PermissionType.EXPLICIT;\r
+                                       editable = true;\r
+                               }\r
+                               list.add(new RegistrantAccessPermission(team.name, ap, pType, RegistrantType.TEAM, editable));\r
                        }\r
                }\r
+               Collections.sort(list);\r
                return list;\r
        }\r
 \r
@@ -566,6 +607,15 @@ public class GitblitClient implements Serializable {
        public List<RepositoryModel> getRepositories() {\r
                return allRepositories;\r
        }\r
+       \r
+       public RepositoryModel getRepository(String name) {\r
+               for (RepositoryModel repository : allRepositories) {\r
+                       if (repository.name.equalsIgnoreCase(name)) {\r
+                               return repository;\r
+                       }\r
+               }\r
+               return null;\r
+       }\r
 \r
        public boolean createRepository(RepositoryModel repository, List<RegistrantAccessPermission> userPermissions)\r
                        throws IOException {\r
index 4ea173fc3ff2e5ba6a4827ce6f261f5bd33a4dab..b8ab9399c1760894b01af631cf064982261ff88a 100644 (file)
@@ -33,7 +33,10 @@ import javax.swing.SwingConstants;
 import javax.swing.table.DefaultTableCellRenderer;\r
 \r
 import com.gitblit.Constants.AccessPermission;\r
+import com.gitblit.Constants.PermissionType;\r
+import com.gitblit.Constants.RegistrantType;\r
 import com.gitblit.models.RegistrantAccessPermission;\r
+import com.gitblit.utils.StringUtils;\r
 \r
 public class RegistrantPermissionsPanel extends JPanel {\r
 \r
@@ -53,16 +56,19 @@ public class RegistrantPermissionsPanel extends JPanel {
 \r
        private JPanel addPanel;\r
 \r
-       public RegistrantPermissionsPanel() {\r
+       public RegistrantPermissionsPanel(final RegistrantType registrantType) {\r
                super(new BorderLayout(5, 5));\r
                tableModel = new RegistrantPermissionsTableModel();\r
-               permissionsTable = new JTable(tableModel);\r
+               permissionsTable = Utils.newTable(tableModel, Utils.DATE_FORMAT);\r
+               permissionsTable.setModel(tableModel);\r
                permissionsTable.setPreferredScrollableViewportSize(new Dimension(400, 150));\r
                JScrollPane jsp = new JScrollPane(permissionsTable);\r
                add(jsp, BorderLayout.CENTER);\r
                \r
+               permissionsTable.getColumnModel().getColumn(RegistrantPermissionsTableModel.Columns.Registrant.ordinal())\r
+               .setCellRenderer(new NameRenderer());\r
                permissionsTable.getColumnModel().getColumn(RegistrantPermissionsTableModel.Columns.Type.ordinal())\r
-                               .setCellRenderer(new RegexRenderer());\r
+                               .setCellRenderer(new PermissionTypeRenderer());\r
                permissionsTable.getColumnModel().getColumn(RegistrantPermissionsTableModel.Columns.Permission.ordinal())\r
                .setCellEditor(new AccessPermissionEditor());\r
                \r
@@ -79,9 +85,15 @@ public class RegistrantPermissionsPanel extends JPanel {
                                        return;\r
                                }\r
                                \r
-                               RegistrantAccessPermission rp = new RegistrantAccessPermission();\r
+                               RegistrantAccessPermission rp = new RegistrantAccessPermission(registrantType);\r
                                rp.registrant = registrantSelector.getSelectedItem().toString();\r
                                rp.permission = (AccessPermission) permissionSelector.getSelectedItem();\r
+                               if (StringUtils.findInvalidCharacter(rp.registrant) != null) {\r
+                                       rp.permissionType = PermissionType.REGEX;\r
+                               } else {\r
+                                       rp.permissionType = PermissionType.EXPLICIT;\r
+                               }\r
+\r
                                tableModel.permissions.add(rp);\r
                                \r
                                registrantModel.removeElement(rp.registrant);\r
@@ -103,7 +115,10 @@ public class RegistrantPermissionsPanel extends JPanel {
        @Override\r
        public void setEnabled(boolean enabled) {\r
                super.setEnabled(enabled);\r
-               permissionsTable.setEnabled(false);\r
+               permissionsTable.setEnabled(enabled);\r
+               registrantSelector.setEnabled(enabled);\r
+               permissionSelector.setEnabled(enabled);\r
+               addButton.setEnabled(enabled);\r
        }\r
 \r
        public void setObjects(List<String> registrants, List<RegistrantAccessPermission> permissions) {\r
@@ -117,7 +132,11 @@ public class RegistrantPermissionsPanel extends JPanel {
                        permissions = new ArrayList<RegistrantAccessPermission>();\r
                }\r
                for (RegistrantAccessPermission rp : permissions) {\r
-                       filtered.remove(rp.registrant);\r
+                       if (rp.isEditable) {\r
+                               // only remove editable duplicates\r
+                               // this allows for specifying an explicit permission\r
+                               filtered.remove(rp.registrant);\r
+                       }\r
                }\r
                for (String registrant : filtered) {\r
                        registrantModel.addElement(registrant);\r
@@ -138,30 +157,35 @@ public class RegistrantPermissionsPanel extends JPanel {
                private static final long serialVersionUID = 1L;\r
 \r
                public AccessPermissionEditor() {\r
-               super(new JComboBox(AccessPermission.values()));\r
+               super(new JComboBox(AccessPermission.values()));                \r
            }\r
        }\r
        \r
-       private class RegexRenderer extends DefaultTableCellRenderer {\r
+       private class PermissionTypeRenderer extends DefaultTableCellRenderer {\r
 \r
                private static final long serialVersionUID = 1L;\r
 \r
-               public RegexRenderer() {\r
+               public PermissionTypeRenderer() {\r
                        super();\r
                        setHorizontalAlignment(SwingConstants.CENTER);\r
                }\r
 \r
                @Override\r
                protected void setValue(Object value) {\r
-                       boolean isExplicit = (Boolean) value;\r
-                       if (isExplicit) {\r
-                               // explicit permission\r
-                               setText("");\r
-                               setToolTipText(null);\r
-                       } else {\r
-                               // regex matched permission\r
+                       PermissionType pType = (PermissionType) value;\r
+                       switch (pType) {\r
+                       case OWNER:\r
+                               setText("owner");\r
+                               setToolTipText(Translation.get("gb.ownerPermission"));\r
+                               break;\r
+                       case REGEX:\r
                                setText("regex");\r
                                setToolTipText(Translation.get("gb.regexPermission"));\r
+                               break;\r
+                       default:\r
+                               setText("");\r
+                               setToolTipText(null);\r
+                               break;\r
                        }\r
                }\r
        }\r
index fcd9c8b463402691b70d6b5869c28e4b3308dc22..9ed8db4a9c972be42e4cca6c8dbb5adc3ae9cfa3 100644 (file)
@@ -104,7 +104,7 @@ public class RegistrantPermissionsTableModel extends AbstractTableModel {
                        // and therefore can not be directly manipulated unless the current\r
                        // object is the source of the regex (i.e. a user or team with explicit\r
                        // regex definition)\r
-                       return permissions.get(rowIndex).isExplicit;\r
+                       return permissions.get(rowIndex).isEditable;\r
                }\r
                return false;\r
        }\r
@@ -117,7 +117,7 @@ public class RegistrantPermissionsTableModel extends AbstractTableModel {
                case Registrant:\r
                        return rp.registrant;\r
                case Type:\r
-                       return rp.isExplicit;\r
+                       return rp.permissionType;\r
                case Permission:\r
                        return rp.permission;\r
                }\r
index 9fcad7bc22f8e5a7237fa3720ab6f1c95b913429..cd571b269e6161035f6ea3c7828da68ffdf9d3e9 100644 (file)
@@ -40,7 +40,9 @@ import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;\r
 import javax.swing.table.TableRowSorter;\r
 \r
+import com.gitblit.Constants.PermissionType;\r
 import com.gitblit.Constants.RpcRequest;\r
+import com.gitblit.models.RegistrantAccessPermission;\r
 import com.gitblit.models.TeamModel;\r
 import com.gitblit.models.UserModel;\r
 import com.gitblit.utils.StringUtils;\r
@@ -309,6 +311,21 @@ public abstract class UsersPanel extends JPanel {
                                gitblit.getSettings());\r
                dialog.setLocationRelativeTo(UsersPanel.this);\r
                dialog.setUsers(gitblit.getUsers());\r
+               \r
+               List<RegistrantAccessPermission> permissions = user.getRepositoryPermissions();\r
+               for (RegistrantAccessPermission permission : permissions) {\r
+                       if (permission.isEditable && PermissionType.EXPLICIT.equals(permission.permissionType)) {\r
+                               // Ensure this is NOT an owner permission - which is non-editable\r
+                               // We don't know this from within the usermodel, ownership is a\r
+                               // property of a repository.\r
+                               boolean isOwner = gitblit.getRepository(permission.registrant).isOwner(user.username);\r
+                               if (isOwner) {\r
+                                       permission.permissionType = PermissionType.OWNER;\r
+                                       permission.isEditable = false;\r
+                               }\r
+                       }\r
+               }\r
+               \r
                dialog.setRepositories(gitblit.getRepositories(), user.getRepositoryPermissions());\r
                dialog.setTeams(gitblit.getTeams(), user.teams == null ? null : new ArrayList<TeamModel>(\r
                                user.teams));\r
index 4a560d43472adfcac4a6468d9ff23d85f71883ed..7346d310ab78abfd5906de7bb75ff078f0eb2f38 100644 (file)
@@ -18,6 +18,7 @@ package com.gitblit.models;
 import java.io.Serializable;
 
 import com.gitblit.Constants.AccessPermission;
+import com.gitblit.Constants.PermissionType;
 import com.gitblit.Constants.RegistrantType;
 import com.gitblit.utils.StringUtils;
 
@@ -32,23 +33,27 @@ public class RegistrantAccessPermission implements Serializable, Comparable<Regi
 
        public String registrant;
        public AccessPermission permission;
-       public RegistrantType type;
-       public boolean isExplicit;
+       public RegistrantType registrantType;
+       public PermissionType permissionType;
+       public boolean isEditable;
 
-       public RegistrantAccessPermission() {
-               isExplicit = true;
+       public RegistrantAccessPermission(RegistrantType registrantType) {
+               this.registrantType = registrantType;
+               this.permissionType = PermissionType.EXPLICIT;
+               this.isEditable = true;
        }
        
-       public RegistrantAccessPermission(String registrant, AccessPermission permission, boolean isExplicit, RegistrantType type) {
+       public RegistrantAccessPermission(String registrant, AccessPermission permission, PermissionType permissionType, RegistrantType registrantType, boolean isEditable) {
                this.registrant = registrant;
                this.permission = permission;
-               this.isExplicit = isExplicit;
-               this.type = type;
+               this.permissionType = permissionType;
+               this.registrantType = registrantType;
+               this.isEditable = isEditable;
        }
        
        @Override
        public int compareTo(RegistrantAccessPermission p) {
-               switch (type) {
+               switch (registrantType) {
                case REPOSITORY:
                        return StringUtils.compareRepositoryNames(registrant, p.registrant);
                default:
@@ -56,6 +61,21 @@ public class RegistrantAccessPermission implements Serializable, Comparable<Regi
                }
        }
        
+       @Override
+       public int hashCode() {
+               return registrant.hashCode();
+       }
+       
+       @Override
+       public boolean equals(Object o) {
+               if (o instanceof RegistrantAccessPermission) {
+                       RegistrantAccessPermission p = (RegistrantAccessPermission) o;
+                       return registrant.equals(p.registrant);
+               }
+               
+               return false;
+       }
+       
        @Override
        public String toString() {
                return permission.asRole(registrant);
index 7d557db97851e9860acaacf77f2679d29c617794..e5e3b097fc0369a9482cb092062ad83d775a00bd 100644 (file)
@@ -27,6 +27,7 @@ import java.util.Set;
 \r
 import com.gitblit.Constants.AccessPermission;\r
 import com.gitblit.Constants.AccessRestrictionType;\r
+import com.gitblit.Constants.PermissionType;\r
 import com.gitblit.Constants.RegistrantType;\r
 import com.gitblit.Constants.Unused;\r
 import com.gitblit.utils.StringUtils;\r
@@ -98,7 +99,14 @@ public class TeamModel implements Serializable, Comparable<TeamModel> {
        public List<RegistrantAccessPermission> getRepositoryPermissions() {\r
                List<RegistrantAccessPermission> list = new ArrayList<RegistrantAccessPermission>();\r
                for (Map.Entry<String, AccessPermission> entry : permissions.entrySet()) {\r
-                       list.add(new RegistrantAccessPermission(entry.getKey(), entry.getValue(), true, RegistrantType.REPOSITORY));\r
+                       String registrant = entry.getKey();\r
+                       boolean editable = true;\r
+                       PermissionType pType = PermissionType.EXPLICIT;\r
+                       if (StringUtils.findInvalidCharacter(registrant) != null) {\r
+                               // a regex will have at least 1 invalid character\r
+                               pType = PermissionType.REGEX;\r
+                       }\r
+                       list.add(new RegistrantAccessPermission(registrant, entry.getValue(), pType, RegistrantType.REPOSITORY, editable));\r
                }\r
                Collections.sort(list);\r
                return list;\r
index d7bc29351f9a384ba5f9e8ccf9748facfdcbb1d8..22f250cc1e86e6f45a0031d82b6d2e333398b56d 100644 (file)
@@ -28,6 +28,7 @@ import java.util.Set;
 import com.gitblit.Constants.AccessPermission;\r
 import com.gitblit.Constants.AccessRestrictionType;\r
 import com.gitblit.Constants.AuthorizationControl;\r
+import com.gitblit.Constants.PermissionType;\r
 import com.gitblit.Constants.RegistrantType;\r
 import com.gitblit.Constants.Unused;\r
 import com.gitblit.utils.ArrayUtils;\r
@@ -137,7 +138,17 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
        public List<RegistrantAccessPermission> getRepositoryPermissions() {\r
                List<RegistrantAccessPermission> list = new ArrayList<RegistrantAccessPermission>();\r
                for (Map.Entry<String, AccessPermission> entry : permissions.entrySet()) {\r
-                       list.add(new RegistrantAccessPermission(entry.getKey(), entry.getValue(), true, RegistrantType.REPOSITORY));\r
+                       String registrant = entry.getKey();\r
+                       boolean editable = true;\r
+                       PermissionType pType = PermissionType.EXPLICIT;\r
+                       if (isMyPersonalRepository(registrant)) {\r
+                               pType = PermissionType.OWNER;\r
+                               editable = false;\r
+                       } else if (StringUtils.findInvalidCharacter(registrant) != null) {\r
+                               // a regex will have at least 1 invalid character\r
+                               pType = PermissionType.REGEX;\r
+                       }\r
+                       list.add(new RegistrantAccessPermission(registrant, entry.getValue(), pType, RegistrantType.REPOSITORY, editable));\r
                }\r
                Collections.sort(list);\r
                return list;\r
@@ -494,4 +505,9 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
                // Default UserModel doesn't implement branch-level security. Other Realms (i.e. Gerrit) may override this method.\r
                return hasRepositoryPermission(repositoryName);\r
        }\r
+       \r
+       public boolean isMyPersonalRepository(String repository) {\r
+               String projectPath = StringUtils.getFirstPathElement(repository);\r
+               return !StringUtils.isEmpty(projectPath) && projectPath.equalsIgnoreCase("~" + username);\r
+       }\r
 }\r
index 62e4817f67e367e747f09c8c004e12ee6ac8e6fe..c6ceb9fdd607da8f65fc3bd07236236748d947e5 100644 (file)
@@ -311,8 +311,8 @@ gb.duration.months = {0} months
 gb.duration.oneYear = 1 year\r
 gb.duration.years = {0} years\r
 gb.authorizationControl = authorization control\r
-gb.allowAuthenticatedDescription = grant restricted access to all authenticated users\r
-gb.allowNamedDescription = grant restricted access to named users or teams\r
+gb.allowAuthenticatedDescription = grant RW+ permission to all authenticated users\r
+gb.allowNamedDescription = grant fine-grained permissions to named users or teams\r
 gb.markdownFailure = Failed to parse Markdown content!\r
 gb.clearCache = clear cache\r
 gb.projects = projects\r
@@ -364,3 +364,4 @@ gb.gcPeriod = GC period
 gb.gcPeriodDescription = duration between garbage collections\r
 gb.gcThreshold = GC threshold\r
 gb.gcThresholdDescription = minimum total size of loose objects to trigger early garbage collection\r
+gb.ownerPermission = repository owner
\ No newline at end of file
index dcca361915d79f9da3bed4922e8ba40f54561d04..ceeb91208f8eeeb745a08c18ae3007253c04e9b3 100644 (file)
@@ -55,6 +55,7 @@ import org.slf4j.LoggerFactory;
 import com.gitblit.Constants;\r
 import com.gitblit.Constants.AccessPermission;\r
 import com.gitblit.Constants.AccessRestrictionType;\r
+import com.gitblit.Constants.AuthorizationControl;\r
 import com.gitblit.Constants.FederationStrategy;\r
 import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
@@ -255,6 +256,21 @@ public abstract class BasePage extends WebPage {
                }\r
                return map;\r
        }\r
+       \r
+       protected Map<AuthorizationControl, String> getAuthorizationControls() {\r
+               Map<AuthorizationControl, String> map = new LinkedHashMap<AuthorizationControl, String>();\r
+               for (AuthorizationControl type : AuthorizationControl.values()) {\r
+                       switch (type) {\r
+                       case AUTHENTICATED:\r
+                               map.put(type, getString("gb.allowAuthenticatedDescription"));\r
+                               break;\r
+                       case NAMED:\r
+                               map.put(type, getString("gb.allowNamedDescription"));\r
+                               break;\r
+                       }\r
+               }\r
+               return map;\r
+       }\r
 \r
        protected TimeZone getTimeZone() {\r
                return GitBlit.getBoolean(Keys.web.useClientTimezone, false) ? GitBlitWebSession.get()\r
index 7bd896cfcee280c8811f1c296221739f265ab90b..638eae90427a6cabbc77aa5308428464c053c577 100644 (file)
                                <tbody class="settings">\r
                                        <tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select class="span4" wicket:id="accessRestriction" tabindex="15" /></td></tr>\r
                                        <tr><th colspan="2"><hr/></th></tr>\r
-                                       <tr><th><wicket:message key="gb.authorizationControl"></wicket:message></th><td style="padding:2px;">\r
-                                               <wicket:container wicket:id="authorizationControl">\r
-                                                       <label class="radio"><input type="radio" wicket:id="allowAuthenticated" tabindex="16" /> &nbsp;<span class="help-inline"><wicket:message key="gb.allowAuthenticatedDescription"></wicket:message></span></label>\r
-                                                       <label class="radio"><input type="radio" wicket:id="allowNamed" tabindex="17" /> &nbsp;<span class="help-inline"><wicket:message key="gb.allowNamedDescription"></wicket:message></span></label>\r
-                                               </wicket:container>\r
-                                       </td></tr>\r
+                                       <tr><th><wicket:message key="gb.authorizationControl"></wicket:message></th><td style="padding:2px;"><span class="authorizationControl" wicket:id="authorizationControl"></span></td></tr>\r
                                        <tr><th colspan="2"><hr/></th></tr>\r
                                        <tr><th><wicket:message key="gb.isFrozen"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="isFrozen" tabindex="18" /> &nbsp;<span class="help-inline"><wicket:message key="gb.isFrozenDescription"></wicket:message></span></label></td></tr>\r
                                        <tr><th><wicket:message key="gb.allowForks"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="allowForks" tabindex="19" /> &nbsp;<span class="help-inline"><wicket:message key="gb.allowForksDescription"></wicket:message></span></label></td></tr>\r
index 1a2e63ce38b52b29553f2ef2e57e36b5f879e003..58fdf66b3aa3763ddf8a902db2d69b77965d8384 100644 (file)
@@ -27,6 +27,9 @@ import java.util.Map;
 import java.util.Set;\r
 \r
 import org.apache.wicket.PageParameters;\r
+import org.apache.wicket.ajax.AjaxRequestTarget;\r
+import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;\r
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;\r
 import org.apache.wicket.behavior.SimpleAttributeModifier;\r
 import org.apache.wicket.extensions.markup.html.form.palette.Palette;\r
 import org.apache.wicket.markup.html.WebMarkupContainer;\r
@@ -36,8 +39,7 @@ import org.apache.wicket.markup.html.form.CheckBox;
 import org.apache.wicket.markup.html.form.DropDownChoice;\r
 import org.apache.wicket.markup.html.form.Form;\r
 import org.apache.wicket.markup.html.form.IChoiceRenderer;\r
-import org.apache.wicket.markup.html.form.Radio;\r
-import org.apache.wicket.markup.html.form.RadioGroup;\r
+import org.apache.wicket.markup.html.form.RadioChoice;\r
 import org.apache.wicket.markup.html.form.TextField;\r
 import org.apache.wicket.markup.html.list.ListItem;\r
 import org.apache.wicket.markup.html.list.ListView;\r
@@ -51,6 +53,7 @@ import com.gitblit.Constants;
 import com.gitblit.Constants.AccessRestrictionType;\r
 import com.gitblit.Constants.AuthorizationControl;\r
 import com.gitblit.Constants.FederationStrategy;\r
+import com.gitblit.Constants.RegistrantType;\r
 import com.gitblit.GitBlit;\r
 import com.gitblit.GitBlitException;\r
 import com.gitblit.Keys;\r
@@ -70,6 +73,8 @@ public class EditRepositoryPage extends RootSubPage {
        private final boolean isCreate;\r
 \r
        private boolean isAdmin;\r
+       \r
+       RepositoryModel repositoryModel;\r
 \r
        private IModel<String> mailingLists;\r
 \r
@@ -97,6 +102,7 @@ public class EditRepositoryPage extends RootSubPage {
                \r
                setupPage(model);\r
                setStatelessHint(false);\r
+               setOutputMarkupId(true);\r
        }\r
 \r
        public EditRepositoryPage(PageParameters params) {\r
@@ -107,9 +113,12 @@ public class EditRepositoryPage extends RootSubPage {
                RepositoryModel model = GitBlit.self().getRepositoryModel(name);\r
                setupPage(model);\r
                setStatelessHint(false);\r
+               setOutputMarkupId(true);\r
        }\r
 \r
-       protected void setupPage(final RepositoryModel repositoryModel) {\r
+       protected void setupPage(RepositoryModel model) {\r
+               this.repositoryModel = model;\r
+               \r
                // ensure this user can create or edit this repository\r
                checkPermissions(repositoryModel);\r
 \r
@@ -145,10 +154,10 @@ public class EditRepositoryPage extends RootSubPage {
 \r
                final String oldName = repositoryModel.name;\r
 \r
-               RegistrantPermissionsPanel usersPalette = new RegistrantPermissionsPanel("users", \r
-                               GitBlit.self().getAllUsernames(), repositoryUsers, getAccessPermissions());\r
-               RegistrantPermissionsPanel teamsPalette = new RegistrantPermissionsPanel("teams", \r
-                               GitBlit.self().getAllTeamnames(), repositoryTeams, getAccessPermissions());\r
+               final RegistrantPermissionsPanel usersPalette = new RegistrantPermissionsPanel("users", \r
+                               RegistrantType.USER, GitBlit.self().getAllUsernames(), repositoryUsers, getAccessPermissions());\r
+               final RegistrantPermissionsPanel teamsPalette = new RegistrantPermissionsPanel("teams", \r
+                               RegistrantType.TEAM, GitBlit.self().getAllTeamnames(), repositoryTeams, getAccessPermissions());\r
 \r
                // indexed local branches palette\r
                List<String> allLocalBranches = new ArrayList<String>();\r
@@ -206,9 +215,9 @@ public class EditRepositoryPage extends RootSubPage {
                };\r
                customFieldsListView.setReuseItems(true);\r
 \r
-               CompoundPropertyModel<RepositoryModel> model = new CompoundPropertyModel<RepositoryModel>(\r
+               CompoundPropertyModel<RepositoryModel> rModel = new CompoundPropertyModel<RepositoryModel>(\r
                                repositoryModel);\r
-               Form<RepositoryModel> form = new Form<RepositoryModel>("editForm", model) {\r
+               Form<RepositoryModel> form = new Form<RepositoryModel>("editForm", rModel) {\r
 \r
                        private static final long serialVersionUID = 1L;\r
 \r
@@ -366,8 +375,9 @@ public class EditRepositoryPage extends RootSubPage {
                form.add(new DropDownChoice<String>("owner", GitBlit.self().getAllUsernames())\r
                                .setEnabled(GitBlitWebSession.get().canAdmin()));\r
                form.add(new CheckBox("allowForks"));\r
-               form.add(new DropDownChoice<AccessRestrictionType>("accessRestriction", Arrays\r
-                               .asList(AccessRestrictionType.values()), new AccessRestrictionRenderer()));\r
+               DropDownChoice<AccessRestrictionType> accessRestriction = new DropDownChoice<AccessRestrictionType>("accessRestriction", Arrays\r
+                               .asList(AccessRestrictionType.values()), new AccessRestrictionRenderer());\r
+               form.add(accessRestriction);\r
                form.add(new CheckBox("isFrozen"));\r
                // TODO enable origin definition\r
                form.add(new TextField<String>("origin").setEnabled(false/* isCreate */));\r
@@ -403,12 +413,10 @@ public class EditRepositoryPage extends RootSubPage {
                form.add(new TextField<String>("mailingLists", mailingLists));\r
                form.add(indexedBranchesPalette);\r
                \r
-               RadioGroup<AuthorizationControl> group = new RadioGroup<AuthorizationControl>("authorizationControl");\r
-               Radio<AuthorizationControl> allowAuthenticated = new Radio<AuthorizationControl>("allowAuthenticated", new Model<AuthorizationControl>(AuthorizationControl.AUTHENTICATED));            \r
-               Radio<AuthorizationControl> allowNamed = new Radio<AuthorizationControl>("allowNamed", new Model<AuthorizationControl>(AuthorizationControl.NAMED));\r
-               group.add(allowAuthenticated);\r
-               group.add(allowNamed);\r
-               form.add(group);\r
+               List<AuthorizationControl> acList = Arrays.asList(AuthorizationControl.values());\r
+               final RadioChoice<AuthorizationControl> authorizationControl = new RadioChoice<Constants.AuthorizationControl>(\r
+                               "authorizationControl", acList, new AuthorizationControlRenderer());\r
+               form.add(authorizationControl);\r
                                \r
                form.add(new CheckBox("verifyCommitter"));\r
 \r
@@ -425,7 +433,69 @@ public class EditRepositoryPage extends RootSubPage {
                WebMarkupContainer customFieldsSection = new WebMarkupContainer("customFieldsSection");\r
                customFieldsSection.add(customFieldsListView);\r
                form.add(customFieldsSection.setVisible(!GitBlit.getString(Keys.groovy.customFields, "").isEmpty()));\r
+               \r
+               // initial enable/disable of permission controls\r
+               if (repositoryModel.accessRestriction.equals(AccessRestrictionType.NONE)) {\r
+                       // anonymous everything, disable all controls\r
+                       usersPalette.setEnabled(false);\r
+                       teamsPalette.setEnabled(false);\r
+                       authorizationControl.setEnabled(false);\r
+               } else {\r
+                       // authenticated something\r
+                       // enable authorization controls\r
+                       authorizationControl.setEnabled(true);\r
+                       \r
+                       boolean allowFineGrainedControls = repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED);\r
+                       usersPalette.setEnabled(allowFineGrainedControls);\r
+                       teamsPalette.setEnabled(allowFineGrainedControls);                      \r
+               }\r
+               \r
+               accessRestriction.add(new AjaxFormComponentUpdatingBehavior("onchange") {\r
+                  \r
+                       private static final long serialVersionUID = 1L;\r
+\r
+                       protected void onUpdate(AjaxRequestTarget target) {\r
+                               // enable/disable permissions panel based on access restriction\r
+                               boolean allowAuthorizationControl = repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE);\r
+                               authorizationControl.setEnabled(allowAuthorizationControl);\r
+                               \r
+                               boolean allowFineGrainedControls = allowAuthorizationControl && repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED);\r
+                               usersPalette.setEnabled(allowFineGrainedControls);\r
+                               teamsPalette.setEnabled(allowFineGrainedControls);\r
+                               \r
+                               if (allowFineGrainedControls) {\r
+                                       repositoryModel.authorizationControl = AuthorizationControl.NAMED;\r
+                               }\r
+                               \r
+                               target.addComponent(authorizationControl);\r
+                               target.addComponent(usersPalette);\r
+                               target.addComponent(teamsPalette);\r
+                       }\r
+               });\r
+               \r
+               authorizationControl.add(new AjaxFormChoiceComponentUpdatingBehavior() {\r
+                  \r
+                       private static final long serialVersionUID = 1L;\r
 \r
+                       protected void onUpdate(AjaxRequestTarget target) {\r
+                               // enable/disable permissions panel based on access restriction\r
+                               boolean allowAuthorizationControl = repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE);\r
+                               authorizationControl.setEnabled(allowAuthorizationControl);\r
+                               \r
+                               boolean allowFineGrainedControls = allowAuthorizationControl && repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED);\r
+                               usersPalette.setEnabled(allowFineGrainedControls);\r
+                               teamsPalette.setEnabled(allowFineGrainedControls);\r
+                               \r
+                               if (allowFineGrainedControls) {\r
+                                       repositoryModel.authorizationControl = AuthorizationControl.NAMED;\r
+                               }\r
+                               \r
+                               target.addComponent(authorizationControl);\r
+                               target.addComponent(usersPalette);\r
+                               target.addComponent(teamsPalette);\r
+                       }\r
+               });\r
+               \r
                form.add(new Button("save"));\r
                Button cancel = new Button("cancel") {\r
                        private static final long serialVersionUID = 1L;\r
@@ -528,4 +598,25 @@ public class EditRepositoryPage extends RootSubPage {
                        return Integer.toString(index);\r
                }\r
        }\r
+       \r
+       private class AuthorizationControlRenderer implements IChoiceRenderer<AuthorizationControl> {\r
+\r
+               private static final long serialVersionUID = 1L;\r
+\r
+               private final Map<AuthorizationControl, String> map;\r
+\r
+               public AuthorizationControlRenderer() {\r
+                       map = getAuthorizationControls();\r
+               }\r
+\r
+               @Override\r
+               public String getDisplayValue(AuthorizationControl type) {\r
+                       return map.get(type);\r
+               }\r
+\r
+               @Override\r
+               public String getIdValue(AuthorizationControl type, int index) {\r
+                       return Integer.toString(index);\r
+               }\r
+       }\r
 }\r
index 8908676e8639bad6a52bc3f1075e607ab50c8962..8ced03c24dc9fb63877ba419682b536e88513640 100644 (file)
@@ -38,6 +38,7 @@ import org.apache.wicket.model.util.ListModel;
 \r
 import com.gitblit.GitBlit;\r
 import com.gitblit.GitBlitException;\r
+import com.gitblit.Constants.RegistrantType;\r
 import com.gitblit.models.RegistrantAccessPermission;\r
 import com.gitblit.models.TeamModel;\r
 import com.gitblit.utils.StringUtils;\r
@@ -60,6 +61,7 @@ public class EditTeamPage extends RootSubPage {
                isCreate = true;\r
                setupPage(new TeamModel(""));\r
                setStatelessHint(false);\r
+               setOutputMarkupId(true);\r
        }\r
 \r
        public EditTeamPage(PageParameters params) {\r
@@ -70,6 +72,7 @@ public class EditTeamPage extends RootSubPage {
                TeamModel model = GitBlit.self().getTeamModel(name);\r
                setupPage(model);\r
                setStatelessHint(false);\r
+               setOutputMarkupId(true);\r
        }\r
 \r
        protected void setupPage(final TeamModel teamModel) {\r
@@ -81,7 +84,7 @@ public class EditTeamPage extends RootSubPage {
 \r
                CompoundPropertyModel<TeamModel> model = new CompoundPropertyModel<TeamModel>(teamModel);\r
 \r
-               List<String> repos = getAccessRestrictedRepositoryList(true);\r
+               List<String> repos = getAccessRestrictedRepositoryList(true, null);\r
 \r
                List<String> teamUsers = new ArrayList<String>(teamModel.users);\r
                Collections.sort(teamUsers);\r
@@ -215,7 +218,8 @@ public class EditTeamPage extends RootSubPage {
                                : StringUtils.flattenStrings(teamModel.mailingLists, " "));\r
                form.add(new TextField<String>("mailingLists", mailingLists));\r
 \r
-               form.add(new RegistrantPermissionsPanel("repositories", repos, permissions, getAccessPermissions()));\r
+               form.add(new RegistrantPermissionsPanel("repositories", RegistrantType.REPOSITORY,\r
+                               repos, permissions, getAccessPermissions()));\r
                form.add(preReceivePalette);\r
                form.add(new BulletListPanel("inheritedPreReceive", "inherited", GitBlit.self()\r
                                .getPreReceiveScriptsInherited(null)));\r
index a165305d91710f7d0aeb8b124183f6dab809672c..19d297b1478605589062e49a381a4e8fcb000732 100644 (file)
@@ -37,6 +37,8 @@ import org.apache.wicket.model.util.ListModel;
 import com.gitblit.GitBlit;\r
 import com.gitblit.GitBlitException;\r
 import com.gitblit.Keys;\r
+import com.gitblit.Constants.PermissionType;\r
+import com.gitblit.Constants.RegistrantType;\r
 import com.gitblit.models.RegistrantAccessPermission;\r
 import com.gitblit.models.TeamModel;\r
 import com.gitblit.models.UserModel;\r
@@ -61,6 +63,7 @@ public class EditUserPage extends RootSubPage {
                isCreate = true;\r
                setupPage(new UserModel(""));\r
                setStatelessHint(false);\r
+               setOutputMarkupId(true);\r
        }\r
 \r
        public EditUserPage(PageParameters params) {\r
@@ -71,6 +74,7 @@ public class EditUserPage extends RootSubPage {
                UserModel model = GitBlit.self().getUserModel(name);\r
                setupPage(model);\r
                setStatelessHint(false);\r
+               setOutputMarkupId(true);\r
        }\r
 \r
        protected void setupPage(final UserModel userModel) {\r
@@ -85,7 +89,7 @@ public class EditUserPage extends RootSubPage {
                CompoundPropertyModel<UserModel> model = new CompoundPropertyModel<UserModel>(userModel);\r
 \r
                // build list of projects including all repositories wildcards\r
-               List<String> repos = getAccessRestrictedRepositoryList(true);\r
+               List<String> repos = getAccessRestrictedRepositoryList(true, userModel);\r
                \r
                List<String> userTeams = new ArrayList<String>();\r
                for (TeamModel team : userModel.teams) {\r
@@ -95,6 +99,18 @@ public class EditUserPage extends RootSubPage {
                \r
                final String oldName = userModel.username;\r
                final List<RegistrantAccessPermission> permissions = userModel.getRepositoryPermissions();\r
+               for (RegistrantAccessPermission permission : permissions) {\r
+                       if (permission.isEditable && PermissionType.EXPLICIT.equals(permission.permissionType)) {\r
+                               // Ensure this is NOT an owner permission - which is non-editable\r
+                               // We don't know this from within the usermodel, ownership is a\r
+                               // property of a repository.\r
+                               boolean isOwner = GitBlit.self().getRepositoryModel(permission.registrant).isOwner(oldName);\r
+                               if (isOwner) {\r
+                                       permission.permissionType = PermissionType.OWNER;\r
+                                       permission.isEditable = false;\r
+                               }\r
+                       }\r
+               }\r
 \r
                final Palette<String> teams = new Palette<String>("teams", new ListModel<String>(\r
                                new ArrayList<String>(userTeams)), new CollectionModel<String>(GitBlit.self()\r
@@ -228,7 +244,7 @@ public class EditUserPage extends RootSubPage {
                form.add(new CheckBox("canFork"));\r
                form.add(new CheckBox("canCreate"));\r
                form.add(new CheckBox("excludeFromFederation"));\r
-               form.add(new RegistrantPermissionsPanel("repositories", repos, permissions, getAccessPermissions()));\r
+               form.add(new RegistrantPermissionsPanel("repositories", RegistrantType.REPOSITORY, repos, permissions, getAccessPermissions()));\r
                form.add(teams.setEnabled(editTeams));\r
 \r
                form.add(new Button("save"));\r
index 30d296edd1e93f463dacda893c64fda9717bff9f..891c892af5594c45d6c7be3d07b2d7a7a9c7c6c9 100644 (file)
@@ -21,9 +21,11 @@ import java.util.List;
 import org.apache.wicket.PageParameters;\r
 import org.apache.wicket.markup.html.basic.Label;\r
 \r
-import com.gitblit.GitBlit;\r
 import com.gitblit.Constants.AccessRestrictionType;\r
+import com.gitblit.Constants.AuthorizationControl;\r
+import com.gitblit.GitBlit;\r
 import com.gitblit.models.RepositoryModel;\r
+import com.gitblit.models.UserModel;\r
 import com.gitblit.utils.StringUtils;\r
 \r
 /**\r
@@ -52,7 +54,7 @@ public abstract class RootSubPage extends RootPage {
                super.setupPage("", pageName);\r
        }\r
        \r
-       protected List<String> getAccessRestrictedRepositoryList(boolean includeWildcards) {\r
+       protected List<String> getAccessRestrictedRepositoryList(boolean includeWildcards, UserModel user) {\r
                // build list of access-restricted projects\r
                String lastProject = null;\r
                List<String> repos = new ArrayList<String>();\r
@@ -62,19 +64,26 @@ public abstract class RootSubPage extends RootPage {
                        // all repositories excluding personal repositories\r
                        repos.add("[^~].*");\r
                }\r
+               \r
                for (String repo : GitBlit.self().getRepositoryList()) {\r
                        RepositoryModel repositoryModel = GitBlit.self().getRepositoryModel(repo);\r
-                       if (repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE)) {\r
+                       if (repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE)\r
+                                       && repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED)) {\r
+                               if (user != null &&\r
+                                               (repositoryModel.isOwner(user.username) || repositoryModel.isUsersPersonalRepository(user.username))) {\r
+                                       // exclude Owner or personal repositories\r
+                                       continue;\r
+                               }\r
                                if (includeWildcards) {\r
                                        if (lastProject == null || !lastProject.equalsIgnoreCase(repositoryModel.projectPath)) {\r
-                                               lastProject = repositoryModel.projectPath;\r
+                                               lastProject = repositoryModel.projectPath.toLowerCase();\r
                                                if (!StringUtils.isEmpty(repositoryModel.projectPath)) {\r
                                                        // regex for all repositories within a project\r
                                                        repos.add(repositoryModel.projectPath + "/.*");\r
                                                }\r
                                        }\r
                                }\r
-                               repos.add(repo);\r
+                               repos.add(repo.toLowerCase());\r
                        }\r
                }\r
                return repos;\r
index 4c8c4efd8efbf97fa98aee31a5c27591b85e9f93..31f0b6bee96b74fda109a010f55445e5aabe419d 100644 (file)
@@ -9,7 +9,7 @@
 \r
        <div wicket:id="permissionRow">\r
                <div style="padding-top:10px;border-left:1px solid #ccc;border-right:1px solid #ccc;" class="row-fluid">\r
-                       <div style="padding-top:5px;padding-left:5px;" class="span6"><span wicket:id="registrant"></span></div><div style="padding-top:5px;padding-right:5px;text-align:right;" class="span2"><span class="label label-info" wicket:id="regex">[regex]</span></div> <select class="input-medium" wicket:id="permission"></select>\r
+                       <div style="padding-top:5px;padding-left:5px" class="span6"><span wicket:id="registrant"></span></div><div style="padding-top:5px;padding-right:5px;text-align:right;" class="span2"><span class="label" wicket:id="pType">[permission type]</span></div> <select class="input-medium" wicket:id="permission"></select>\r
                </div>\r
        </div>\r
 \r
index b6ed890f1d48194f141f31e7793312b8fbfd755a..27e48fbe8bfae3330d4f11c5d2fb6df78cda3849 100644 (file)
@@ -36,6 +36,7 @@ import org.apache.wicket.model.CompoundPropertyModel;
 import org.apache.wicket.model.IModel;
 
 import com.gitblit.Constants.AccessPermission;
+import com.gitblit.Constants.PermissionType;
 import com.gitblit.Constants.RegistrantType;
 import com.gitblit.models.RegistrantAccessPermission;
 import com.gitblit.utils.DeepCopier;
@@ -52,8 +53,9 @@ public class RegistrantPermissionsPanel extends BasePanel {
 
        private static final long serialVersionUID = 1L;
 
-       public RegistrantPermissionsPanel(String wicketId, List<String> allRegistrants, final List<RegistrantAccessPermission> permissions, final Map<AccessPermission, String> translations) {
+       public RegistrantPermissionsPanel(String wicketId, RegistrantType registrantType, List<String> allRegistrants, final List<RegistrantAccessPermission> permissions, final Map<AccessPermission, String> translations) {
                super(wicketId);
+               setOutputMarkupId(true);
                
                // update existing permissions repeater
                RefreshingView<RegistrantAccessPermission> dataView = new RefreshingView<RegistrantAccessPermission>("permissionRow") {
@@ -80,22 +82,40 @@ public class RegistrantPermissionsPanel extends BasePanel {
             
                        public void populateItem(final Item<RegistrantAccessPermission> item) {
                                final RegistrantAccessPermission entry = item.getModelObject();
-                               if (RegistrantType.REPOSITORY.equals(entry.type)) {
-                                       // repository, strip .git and show swatch
+                               if (RegistrantType.REPOSITORY.equals(entry.registrantType)) {
                                        String repoName = StringUtils.stripDotGit(entry.registrant);
-                                       Label registrant = new Label("registrant", repoName);
-                                       WicketUtils.setCssClass(registrant, "repositorySwatch");
-                                       WicketUtils.setCssBackground(registrant, repoName);
-                                       item.add(registrant);
+                                       if (StringUtils.findInvalidCharacter(repoName) == null) {
+                                               // repository, strip .git and show swatch
+                                               Label registrant = new Label("registrant", repoName);
+                                               WicketUtils.setCssClass(registrant, "repositorySwatch");
+                                               WicketUtils.setCssBackground(registrant, repoName);
+                                               item.add(registrant);
+                                       } else {
+                                               // likely a regex
+                                               Label label = new Label("registrant", entry.registrant);
+                                               WicketUtils.setCssStyle(label, "font-weight: bold;");
+                                               item.add(label);
+                                       }
                                } else {
-                                       item.add(new Label("registrant", entry.registrant));
+                                       // user or team
+                                       Label label = new Label("registrant", entry.registrant);
+                                       WicketUtils.setCssStyle(label, "font-weight: bold;");
+                                       item.add(label);
                                }
-                               if (entry.isExplicit) {
-                                       item.add(new Label("regex", "").setVisible(false));
-                               } else {
-                                       Label regex = new Label("regex", "regex");
+                               switch (entry.permissionType) {
+                               case OWNER:
+                                       Label owner = new Label("pType", "owner");
+                                       WicketUtils.setHtmlTooltip(owner, getString("gb.ownerPermission"));
+                                       item.add(owner);
+                                       break;
+                               case REGEX:
+                                       Label regex = new Label("pType", "regex");
                                        WicketUtils.setHtmlTooltip(regex, getString("gb.regexPermission"));
                                        item.add(regex);
+                                       break;
+                               default:
+                                       item.add(new Label("pType", "").setVisible(false));
+                                       break;
                                }
 
                                // use ajax to get immediate update of permission level change
@@ -106,8 +126,9 @@ public class RegistrantPermissionsPanel extends BasePanel {
                                // only allow changing an explicitly defined permission
                                // this is designed to prevent changing a regex permission in
                                // a repository
-                               permissionChoice.setEnabled(entry.isExplicit);
-                               if (entry.isExplicit) {
+                               permissionChoice.setEnabled(entry.isEditable);
+                               permissionChoice.setOutputMarkupId(true);
+                               if (entry.isEditable) {
                                        permissionChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                           
                                                private static final long serialVersionUID = 1L;
@@ -127,11 +148,15 @@ public class RegistrantPermissionsPanel extends BasePanel {
                // filter out registrants we already have permissions for
                final List<String> registrants = new ArrayList<String>(allRegistrants);
                for (RegistrantAccessPermission rp : permissions) {
-                       registrants.remove(rp.registrant);
+                       if (rp.isEditable) {
+                               // only remove editable duplicates
+                               // this allows for specifying an explicit permission
+                               registrants.remove(rp.registrant);
+                       }
                }
 
                // add new permission form
-               IModel<RegistrantAccessPermission> addPermissionModel = new CompoundPropertyModel<RegistrantAccessPermission>(new RegistrantAccessPermission());
+               IModel<RegistrantAccessPermission> addPermissionModel = new CompoundPropertyModel<RegistrantAccessPermission>(new RegistrantAccessPermission(registrantType));
                Form<RegistrantAccessPermission> addPermissionForm = new Form<RegistrantAccessPermission>("addPermissionForm", addPermissionModel);
                addPermissionForm.add(new DropDownChoice<String>("registrant", registrants));
                addPermissionForm.add(new DropDownChoice<AccessPermission>("permission", Arrays
@@ -144,7 +169,11 @@ public class RegistrantPermissionsPanel extends BasePanel {
                        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                                // add permission to our list
                                RegistrantAccessPermission rp = (RegistrantAccessPermission) form.getModel().getObject();
-                               permissions.add(DeepCopier.copy(rp));
+                               RegistrantAccessPermission copy = DeepCopier.copy(rp);
+                               if (StringUtils.findInvalidCharacter(copy.registrant) != null) {
+                                       copy.permissionType = PermissionType.REGEX;
+                               }
+                               permissions.add(copy);
                                
                                // remove registrant from available choices
                                registrants.remove(rp.registrant);
@@ -159,6 +188,12 @@ public class RegistrantPermissionsPanel extends BasePanel {
                add(addPermissionForm.setVisible(registrants.size() > 0));
        }
        
+       protected boolean getStatelessHint()
+       {
+               return false;
+       }
+
+       
        private class AccessPermissionRenderer implements IChoiceRenderer<AccessPermission> {
 
                private static final long serialVersionUID = 1L;
index 0be2e02a488e2ddc4e49c2335add5d0520aac01f..3df0ff8ebae7fd04ba852c94f450d68494ee53b1 100644 (file)
@@ -35,6 +35,7 @@ import org.junit.Test;
 import com.gitblit.Constants.AccessPermission;\r
 import com.gitblit.Constants.AccessRestrictionType;\r
 import com.gitblit.Constants.AuthorizationControl;\r
+import com.gitblit.Constants.PermissionType;\r
 import com.gitblit.Constants.RegistrantType;\r
 import com.gitblit.GitBlitException.UnauthorizedException;\r
 import com.gitblit.Keys;\r
@@ -199,7 +200,7 @@ public class RpcTests {
                List<RegistrantAccessPermission> permissions = RpcUtils.getRepositoryMemberPermissions(retrievedRepository, url, account,\r
                                password.toCharArray());\r
                assertEquals("Membership permissions is not empty!", 0, permissions.size());\r
-               permissions.add(new RegistrantAccessPermission(testMember.username, AccessPermission.PUSH, true, RegistrantType.USER));\r
+               permissions.add(new RegistrantAccessPermission(testMember.username, AccessPermission.PUSH, PermissionType.EXPLICIT, RegistrantType.USER, true));\r
                assertTrue(\r
                                "Failed to set member permissions!",\r
                                RpcUtils.setRepositoryMemberPermissions(retrievedRepository, permissions, url, account,\r
@@ -288,7 +289,7 @@ public class RpcTests {
                // set no teams\r
                List<RegistrantAccessPermission> permissions = new ArrayList<RegistrantAccessPermission>();\r
                for (String team : helloworldTeams) {\r
-                       permissions.add(new RegistrantAccessPermission(team, AccessPermission.NONE, true, RegistrantType.TEAM));\r
+                       permissions.add(new RegistrantAccessPermission(team, AccessPermission.NONE, PermissionType.EXPLICIT, RegistrantType.TEAM, true));\r
                }\r
                assertTrue(RpcUtils.setRepositoryTeamPermissions(helloworld, permissions, url, account,\r
                                password.toCharArray()));\r