]> source.dussan.org Git - gitblit.git/commitdiff
Move repository ownership to the UserModel and prepare for project ownership ticket/75 75/75/3
authorJames Moger <james.moger@gitblit.com>
Sun, 8 Jun 2014 14:30:39 +0000 (10:30 -0400)
committerJames Moger <james.moger@gitblit.com>
Fri, 13 Jun 2014 12:00:48 +0000 (08:00 -0400)
47 files changed:
src/main/java/com/gitblit/ConfigUserService.java
src/main/java/com/gitblit/Constants.java
src/main/java/com/gitblit/client/EditRepositoryDialog.java
src/main/java/com/gitblit/client/EditUserDialog.java
src/main/java/com/gitblit/client/GitblitClient.java
src/main/java/com/gitblit/client/RepositoriesPanel.java
src/main/java/com/gitblit/client/RepositoriesTableModel.java
src/main/java/com/gitblit/git/GitblitReceivePack.java
src/main/java/com/gitblit/manager/GitblitManager.java
src/main/java/com/gitblit/manager/IUserManager.java
src/main/java/com/gitblit/manager/ProjectManager.java
src/main/java/com/gitblit/manager/RepositoryManager.java
src/main/java/com/gitblit/manager/UserManager.java
src/main/java/com/gitblit/models/Owner.java [new file with mode: 0644]
src/main/java/com/gitblit/models/RepositoryModel.java
src/main/java/com/gitblit/models/UserModel.java
src/main/java/com/gitblit/servlet/GitFilter.java
src/main/java/com/gitblit/servlet/RpcServlet.java
src/main/java/com/gitblit/tickets/BranchTicketService.java
src/main/java/com/gitblit/tickets/FileTicketService.java
src/main/java/com/gitblit/tickets/RedisTicketService.java
src/main/java/com/gitblit/tickets/TicketNotifier.java
src/main/java/com/gitblit/utils/ModelUtils.java
src/main/java/com/gitblit/utils/RpcUtils.java
src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java
src/main/java/com/gitblit/wicket/pages/ForksPage.java
src/main/java/com/gitblit/wicket/pages/MyDashboardPage.java
src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.java
src/main/java/com/gitblit/wicket/pages/OverviewPage.java
src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
src/main/java/com/gitblit/wicket/pages/RootPage.java
src/main/java/com/gitblit/wicket/pages/RootSubPage.java
src/main/java/com/gitblit/wicket/pages/SummaryPage.java
src/main/java/com/gitblit/wicket/panels/ProjectRepositoryPanel.java
src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java
src/main/java/com/gitblit/wicket/panels/RepositoryNamePanel.java
src/test/config/test-users.conf
src/test/java/com/gitblit/tests/BranchTicketServiceTest.java
src/test/java/com/gitblit/tests/FederationTests.java
src/test/java/com/gitblit/tests/FileTicketServiceTest.java
src/test/java/com/gitblit/tests/GitServletTest.java
src/test/java/com/gitblit/tests/GroovyScriptTest.java
src/test/java/com/gitblit/tests/ModelUtilsTest.java
src/test/java/com/gitblit/tests/PermissionsTest.java
src/test/java/com/gitblit/tests/RedisTicketServiceTest.java
src/test/java/com/gitblit/tests/RpcTests.java
src/test/java/com/gitblit/tests/UserServiceTest.java

index d7d6c14f1664f048f0a3a26fb5a4406ffbc95487..f57bba205d038214ed706629c90b2e42cf69ebfd 100644 (file)
@@ -27,6 +27,7 @@ import java.util.List;
 import java.util.Locale;\r
 import java.util.Map;\r
 import java.util.Set;\r
+import java.util.TreeSet;\r
 import java.util.concurrent.ConcurrentHashMap;\r
 \r
 import org.eclipse.jgit.lib.StoredConfig;\r
@@ -96,6 +97,8 @@ public class ConfigUserService implements IUserService {
 \r
        private static final String STARRED = "starred";\r
 \r
+       private static final String OWNS = "owns";\r
+\r
        private static final String LOCALE = "locale";\r
 \r
        private static final String EMAILONMYTICKETCHANGES = "emailMeOnMyTicketChanges";\r
@@ -617,6 +620,11 @@ public class ConfigUserService implements IUserService {
                                        AccessPermission permission = model.removeRepositoryPermission(oldRole);\r
                                        model.setRepositoryPermission(newRole, permission);\r
                                }\r
+\r
+                               if (model.isOwner(oldRole)) {\r
+                                       model.disown(oldRole);\r
+                                       model.own(newRole);\r
+                               }\r
                        }\r
 \r
                        // identify teams which require role rename\r
@@ -764,6 +772,11 @@ public class ConfigUserService implements IUserService {
                                config.setStringList(USER, model.username, REPOSITORY, permissions);\r
                        }\r
 \r
+                       // project and repository ownership\r
+                       if (model.ownedPaths != null) {\r
+                               config.setStringList(USER, model.username, OWNS, new ArrayList<String>(model.ownedPaths));\r
+                       }\r
+\r
                        // user preferences\r
                        if (model.getPreferences() != null) {\r
                                List<String> starred =  model.getPreferences().getStarredRepositories();\r
@@ -927,13 +940,19 @@ public class ConfigUserService implements IUserService {
                                        }\r
 \r
                                        // starred repositories\r
-                                       Set<String> starred = new HashSet<String>(Arrays.asList(config\r
+                                       Set<String> starred = new TreeSet<String>(Arrays.asList(config\r
                                                        .getStringList(USER, username, STARRED)));\r
                                        for (String repository : starred) {\r
                                                UserRepositoryPreferences prefs = user.getPreferences().getRepositoryPreferences(repository);\r
                                                prefs.starred = true;\r
                                        }\r
 \r
+                                       // repository ownership\r
+                                       Set<String> ownerOf = new TreeSet<String>(Arrays.asList(config.getStringList(USER, username, OWNS)));\r
+                                       for (String path : ownerOf) {\r
+                                               user.own(path);\r
+                                       }\r
+\r
                                        // update cache\r
                                        users.put(user.username, user);\r
                                        if (!StringUtils.isEmpty(user.cookie)) {\r
index 3e307537cfd41350121dc807cb61a2842d4b29c1..97d4c600a99b278afd33532c42acc68eac462239 100644 (file)
@@ -365,6 +365,7 @@ public class Constants {
                CREATE_REPOSITORY, EDIT_REPOSITORY, DELETE_REPOSITORY,\r
                LIST_USERS, CREATE_USER, EDIT_USER, DELETE_USER,\r
                LIST_TEAMS, CREATE_TEAM, EDIT_TEAM, DELETE_TEAM,\r
+               LIST_REPOSITORY_OWNERS, SET_REPOSITORY_OWNERS,\r
                LIST_REPOSITORY_MEMBERS, SET_REPOSITORY_MEMBERS, LIST_REPOSITORY_TEAMS, SET_REPOSITORY_TEAMS,\r
                LIST_REPOSITORY_MEMBER_PERMISSIONS, SET_REPOSITORY_MEMBER_PERMISSIONS, LIST_REPOSITORY_TEAM_PERMISSIONS, SET_REPOSITORY_TEAM_PERMISSIONS,\r
                LIST_FEDERATION_REGISTRATIONS, LIST_FEDERATION_RESULTS, LIST_FEDERATION_PROPOSALS, LIST_FEDERATION_SETS,\r
index ef665d10e21cd752670148c522214a90e6e59adc..a7cf4510b876604b244054246071f2e059bf8363 100644 (file)
@@ -579,8 +579,6 @@ public class EditRepositoryDialog extends JDialog {
 \r
                repository.name = rname;\r
                repository.description = descriptionField.getText();\r
-               repository.owners.clear();\r
-               repository.owners.addAll(ownersPalette.getSelections());\r
                repository.HEAD = headRefField.getSelectedItem() == null ? null\r
                                : headRefField.getSelectedItem().toString();\r
                repository.gcPeriod = (Integer) gcPeriod.getSelectedItem();\r
@@ -722,6 +720,10 @@ public class EditRepositoryDialog extends JDialog {
                return teamsPalette.getPermissions();\r
        }\r
 \r
+       public List<String> getOwners() {\r
+               return ownersPalette.getSelections();\r
+       }\r
+\r
        public void setCustomFields(RepositoryModel repository, Map<String, String> customFields) {\r
                customFieldsPanel.removeAll();\r
                customTextfields = new ArrayList<JTextField>();\r
index 676916b2330f94a0e96503c4c4e7f4990a5e0758..4d0c1c8e392234dc3ff18c437c9ac5be1f38331b 100644 (file)
@@ -393,7 +393,7 @@ public class EditUserDialog extends JDialog {
                List<String> restricted = new ArrayList<String>();\r
                for (RepositoryModel repo : repositories) {\r
                        // exclude Owner or personal repositories\r
-                       if (!repo.isOwner(username) && !repo.isUsersPersonalRepository(username)) {\r
+                       if (!user.isOwner(repo)) {\r
                                if (repo.accessRestriction.exceeds(AccessRestrictionType.NONE)\r
                                                && repo.authorizationControl.equals(AuthorizationControl.NAMED)) {\r
                                        restricted.add(repo.name);\r
@@ -456,7 +456,7 @@ public class EditUserDialog extends JDialog {
                                        permission.mutable = false;\r
                                        continue;\r
                                }\r
-                               boolean isOwner = rm.isOwner(username);\r
+                               boolean isOwner = user.isOwner(rm);\r
                                if (isOwner) {\r
                                        permission.permissionType = PermissionType.OWNER;\r
                                        permission.mutable = false;\r
index 66625a8eaff6eb60927715475344686c17fe2c93..1477dac7f2aa20e68248f3166bef27e823544278 100644 (file)
@@ -162,7 +162,17 @@ public class GitblitClient implements Serializable {
        }\r
 \r
        public boolean isOwner(RepositoryModel model) {\r
-               return model.isOwner(account);\r
+               return getUser(account).isOwner(model);\r
+       }\r
+\r
+       public List<String> getOwners(RepositoryModel model) {\r
+               List<String> list = new ArrayList<String>();\r
+               for (UserModel user : allUsers) {\r
+                       if (user.isOwner(model)) {\r
+                               list.add(user.username);\r
+                       }\r
+               }\r
+               return list;\r
        }\r
 \r
        public String getURL(String action, String repository, String objectId) {\r
@@ -529,10 +539,9 @@ public class GitblitClient implements Serializable {
                        }\r
                }\r
 \r
-               // TODO reconsider ownership as a user property\r
                // manually specify personal repository ownerships\r
                for (RepositoryModel rm : allRepositories) {\r
-                       if (rm.isUsersPersonalRepository(user.username) || rm.isOwner(user.username)) {\r
+                       if (user.isOwner(rm)) {\r
                                RegistrantAccessPermission rp = new RegistrantAccessPermission(rm.name, AccessPermission.REWIND,\r
                                                PermissionType.OWNER, RegistrantType.REPOSITORY, null, false);\r
                                // user may be owner of a repository to which they've inherited\r
@@ -660,13 +669,18 @@ public class GitblitClient implements Serializable {
 \r
        public boolean updateRepository(String name, RepositoryModel repository,\r
                        List<RegistrantAccessPermission> userPermissions) throws IOException {\r
-               return updateRepository(name, repository, userPermissions, null);\r
+               return updateRepository(name, repository, null, userPermissions, null);\r
        }\r
 \r
-       public boolean updateRepository(String name, RepositoryModel repository,\r
+       public boolean updateRepository(String name, RepositoryModel repository, List<String> owners,\r
                        List<RegistrantAccessPermission> userPermissions,       List<RegistrantAccessPermission> teamPermissions) throws IOException {\r
                boolean success = true;\r
                success &= RpcUtils.updateRepository(name, repository, url, account, password);\r
+               // set the repository owners\r
+               if (owners != null) {\r
+                       success &= RpcUtils.setRepositoryOwners(repository, owners, url, account, password);\r
+               }\r
+\r
                // set the repository members\r
                if (userPermissions != null) {\r
                        success &= RpcUtils.setRepositoryMemberPermissions(repository, userPermissions, url, account,\r
index 0fab934da6b4678271e6889346fc188fc26ab75e..7e3d96ac579cc4f6836bcd23df578bdd3eceb351 100644 (file)
@@ -194,7 +194,6 @@ public abstract class RepositoriesPanel extends JPanel {
 \r
                setRepositoryRenderer(RepositoriesTableModel.Columns.Name, nameRenderer, -1);\r
                setRepositoryRenderer(RepositoriesTableModel.Columns.Indicators, typeRenderer, 100);\r
-               setRepositoryRenderer(RepositoriesTableModel.Columns.Owner, ownerRenderer, -1);\r
                setRepositoryRenderer(RepositoriesTableModel.Columns.Size, sizeRenderer, 60);\r
 \r
                table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {\r
@@ -466,7 +465,8 @@ public abstract class RepositoriesPanel extends JPanel {
                dialog.setLocationRelativeTo(RepositoriesPanel.this);\r
                List<String> usernames = gitblit.getUsernames();\r
                List<RegistrantAccessPermission> members = gitblit.getUserAccessPermissions(repository);\r
-               dialog.setUsers(new ArrayList<String>(repository.owners), usernames, members);\r
+               List<String> owners = gitblit.getOwners(repository);\r
+               dialog.setUsers(owners, usernames, members);\r
                dialog.setTeams(gitblit.getTeamnames(), gitblit.getTeamAccessPermissions(repository));\r
                dialog.setRepositories(gitblit.getRepositories());\r
                dialog.setFederationSets(gitblit.getFederationSets(), repository.federationSets);\r
@@ -486,6 +486,7 @@ public abstract class RepositoriesPanel extends JPanel {
                final RepositoryModel revisedRepository = dialog.getRepository();\r
                final List<RegistrantAccessPermission> permittedUsers = dialog.getUserAccessPermissions();\r
                final List<RegistrantAccessPermission> permittedTeams = dialog.getTeamAccessPermissions();\r
+               final List<String> newOwners = dialog.getOwners();\r
                if (revisedRepository == null) {\r
                        return;\r
                }\r
@@ -494,7 +495,7 @@ public abstract class RepositoriesPanel extends JPanel {
 \r
                        @Override\r
                        protected Boolean doRequest() throws IOException {\r
-                               boolean success = gitblit.updateRepository(repository.name, revisedRepository,\r
+                               boolean success = gitblit.updateRepository(repository.name, revisedRepository, newOwners,\r
                                                permittedUsers, permittedTeams);\r
                                if (success) {\r
                                        gitblit.refreshRepositories();\r
index 0d26e42c48de047cc33f992b41c3f5dbb1f1ee8e..f93f004ae2b3ce0bbe5f53e3e9067af5d7d544eb 100644 (file)
@@ -23,7 +23,6 @@ import java.util.List;
 import javax.swing.table.AbstractTableModel;\r
 \r
 import com.gitblit.models.RepositoryModel;\r
-import com.gitblit.utils.ArrayUtils;\r
 \r
 /**\r
  * Table model of a list of repositories.\r
@@ -38,7 +37,7 @@ public class RepositoriesTableModel extends AbstractTableModel {
        List<RepositoryModel> list;\r
 \r
        enum Columns {\r
-               Name, Description, Owner, Indicators, Last_Change, Size;\r
+               Name, Description, Indicators, Last_Change, Size;\r
 \r
                @Override\r
                public String toString() {\r
@@ -73,8 +72,6 @@ public class RepositoriesTableModel extends AbstractTableModel {
                        return Translation.get("gb.name");\r
                case Description:\r
                        return Translation.get("gb.description");\r
-               case Owner:\r
-                       return Translation.get("gb.owner");\r
                case Last_Change:\r
                        return Translation.get("gb.lastChange");\r
                case Size:\r
@@ -112,8 +109,6 @@ public class RepositoriesTableModel extends AbstractTableModel {
                        return model;\r
                case Description:\r
                        return model.description;\r
-               case Owner:\r
-                       return ArrayUtils.toString(model.owners);\r
                case Indicators:\r
                        return model;\r
                case Last_Change:\r
index 34bbea27a24755915acaabee2074271c5d437c39..0090930ae665b93b37709146f0354c43caa3ebb4 100644 (file)
@@ -286,7 +286,7 @@ public class GitblitReceivePack extends ReceivePack implements PreReceiveHook, P
                        } else if (ref.equals(BranchTicketService.BRANCH)) {\r
                                // ensure pushing user is an administrator OR an owner\r
                                // i.e. prevent ticket tampering\r
-                               boolean permitted = user.canAdmin() || repository.isOwner(user.username);\r
+                               boolean permitted = user.canAdmin() || user.isOwner(repository);\r
                                if (!permitted) {\r
                                        sendRejection(cmd, "{0} is not permitted to push to {1}", user.username, ref);\r
                                }\r
index 98ad33e737ac26f48853ed95e54bdae36ba23ab1..54ed0ed281d432253232ae3e6ae862d2c7ce90bc 100644 (file)
@@ -62,6 +62,7 @@ import com.gitblit.models.ForkModel;
 import com.gitblit.models.GitClientApplication;
 import com.gitblit.models.Mailing;
 import com.gitblit.models.Metric;
+import com.gitblit.models.Owner;
 import com.gitblit.models.PluginRegistry.InstallState;
 import com.gitblit.models.PluginRegistry.PluginRegistration;
 import com.gitblit.models.PluginRegistry.PluginRelease;
@@ -78,7 +79,6 @@ import com.gitblit.models.UserModel;
 import com.gitblit.tickets.ITicketService;
 import com.gitblit.transport.ssh.IPublicKeyManager;
 import com.gitblit.transport.ssh.SshKey;
-import com.gitblit.utils.ArrayUtils;
 import com.gitblit.utils.HttpUtils;
 import com.gitblit.utils.JsonUtils;
 import com.gitblit.utils.ObjectCache;
@@ -176,7 +176,7 @@ public class GitblitManager implements IGitblit {
         */
        @Override
        public RepositoryModel fork(RepositoryModel repository, UserModel user) throws GitBlitException {
-               String cloneName = MessageFormat.format("{0}/{1}.git", user.getPersonalPath(), StringUtils.stripDotGit(StringUtils.getLastPathElement(repository.name)));
+               String cloneName = MessageFormat.format("{0}{1}.git", user.getPersonalPath(), StringUtils.stripDotGit(StringUtils.getLastPathElement(repository.name)));
                String fromUrl = MessageFormat.format("file://{0}/{1}", repositoryManager.getRepositoriesFolder().getAbsolutePath(), repository.name);
 
                // clone the repository
@@ -214,18 +214,20 @@ public class GitblitManager implements IGitblit {
 
                // create a Gitblit repository model for the clone
                RepositoryModel cloneModel = repository.cloneAs(cloneName);
-               // owner has REWIND/RW+ permissions
-               cloneModel.addOwner(user.username);
                repositoryManager.updateRepositoryModel(cloneName, cloneModel, false);
 
-               // add the owner of the source repository to the clone's access list
-               if (!ArrayUtils.isEmpty(repository.owners)) {
-                       for (String owner : repository.owners) {
-                               UserModel originOwner = userManager.getUserModel(owner);
-                               if (originOwner != null && !originOwner.canClone(cloneModel)) {
+               // owner has REWIND/RW+ permissions
+               user.own(cloneModel);
+               reviseUser(user.username, user);
+
+               // add the owners of the source repository to the clone's access list
+               for (Owner owner : getOwners(repository)) {
+                       if (owner instanceof UserModel) {
+                               UserModel userOwner = (UserModel) owner;
+                               if (!userOwner.canClone(cloneModel)) {
                                        // origin owner can't yet clone fork, grant explicit clone access
-                                       originOwner.setRepositoryPermission(cloneName, AccessPermission.CLONE);
-                                       reviseUser(originOwner.username, originOwner);
+                                       userOwner.setRepositoryPermission(cloneName, AccessPermission.CLONE);
+                                       reviseUser(userOwner.username, userOwner);
                                }
                        }
                }
@@ -325,22 +327,6 @@ public class GitblitManager implements IGitblit {
                                                user.username));
                        }
 
-                       // rename repositories and owner fields for all repositories
-                       for (RepositoryModel model : repositoryManager.getRepositoryModels(user)) {
-                               if (model.isUsersPersonalRepository(username)) {
-                                       // personal repository
-                                       model.addOwner(user.username);
-                                       String oldRepositoryName = model.name;
-                                       model.name = user.getPersonalPath() + model.name.substring(model.projectPath.length());
-                                       model.projectPath = user.getPersonalPath();
-                                       repositoryManager.updateRepositoryModel(oldRepositoryName, model, false);
-                               } else if (model.isOwner(username)) {
-                                       // common/shared repo
-                                       model.addOwner(user.username);
-                                       repositoryManager.updateRepositoryModel(model.name, model, false);
-                               }
-                       }
-
                        // rename the user's ssh public keystore
                        getPublicKeyManager().renameUser(username, user.username);
                }
@@ -880,6 +866,16 @@ public class GitblitManager implements IGitblit {
                return userManager.deleteTeam(teamname);
        }
 
+       @Override
+       public List<Owner> getOwners(RepositoryModel repository) {
+               return userManager.getOwners(repository);
+       }
+
+       @Override
+       public boolean setOwners(RepositoryModel repository, List<Owner> owners) {
+               return userManager.setOwners(repository, owners);
+       }
+
        /*
         * REPOSITORY MANAGER
         */
index b7ea9c464d6d3279cbac69ced254dd96a98b680b..8f969007e8f3653928697d8bfa2b207f2942dcee 100644 (file)
  */
 package com.gitblit.manager;
 
+import java.util.List;
+
 import com.gitblit.IUserService;
+import com.gitblit.models.Owner;
+import com.gitblit.models.RepositoryModel;
 
 public interface IUserManager extends IManager, IUserService {
 
@@ -28,4 +32,32 @@ public interface IUserManager extends IManager, IUserService {
         */
        boolean isInternalAccount(String username);
 
+       /**
+        * Returns the list of repository owners.
+        *
+        * @param repository
+        * @return a list of owners
+        * @since 1.6.0
+        */
+       List<Owner> getOwners(RepositoryModel repository);
+
+       /**
+        * Sets the repository owners.
+        *
+        * @param repository
+        * @param a list of owners
+        * @return true if successful
+        * @since 1.6.0
+        */
+       boolean setOwners(RepositoryModel repository, List<Owner> owners);
+
+//     /**
+//      * Returns the list of project owners.
+//      *
+//      * @param project
+//      * @return a list of owners
+//      * @since 1.6.0
+//      */
+//     List<RepositoryOwner> getOwners(ProjectModel project);
+//
 }
\ No newline at end of file
index b30f4f17be9eea70a323e107afe29d788bb87283..0eb0b1104426f2c474522fbe2076d347065b9895 100644 (file)
@@ -298,14 +298,14 @@ public class ProjectManager implements IProjectManager {
                                // exclude personal repositories
                                continue;
                        }
-                       if (!projects.containsKey(repository.projectPath)) {
-                               ProjectModel project = getProjectModel(repository.projectPath);
+                       if (!projects.containsKey(repository.getProject())) {
+                               ProjectModel project = getProjectModel(repository.getProject());
                                if (project == null) {
                                        logger.warn(MessageFormat.format("excluding project \"{0}\" from project list because it is empty!",
-                                                       repository.projectPath));
+                                                       repository.getProject()));
                                        continue;
                                }
-                               projects.put(repository.projectPath, project);
+                               projects.put(repository.getProject(), project);
                                // clear the repo list in the project because that is the system
                                // list, not the user-accessible list and start building the
                                // user-accessible list
@@ -315,7 +315,7 @@ public class ProjectManager implements IProjectManager {
                        } else {
                                // update the user-accessible list
                                // this is used for repository count
-                               ProjectModel project = projects.get(repository.projectPath);
+                               ProjectModel project = projects.get(repository.getProject());
                                project.repositories.add(repository.name);
                                if (project.lastChange.before(repository.lastChange)) {
                                        project.lastChange = repository.lastChange;
index e0721c7c0a80a40c6f29256edfc38843b1349ec7..29a63eaa3929704388d131281b63550700b5dee4 100644 (file)
@@ -277,10 +277,9 @@ public class RepositoryManager implements IRepositoryManager {
                        }
                }
 
-               // TODO reconsider ownership as a user property
                // manually specify personal repository ownerships
                for (RepositoryModel rm : repositoryListCache.values()) {
-                       if (rm.isUsersPersonalRepository(user.username) || rm.isOwner(user.username)) {
+                       if (user.isOwner(rm)) {
                                RegistrantAccessPermission rp = new RegistrantAccessPermission(rm.name, AccessPermission.REWIND,
                                                PermissionType.OWNER, RegistrantType.REPOSITORY, null, false);
                                // user may be owner of a repository to which they've inherited
@@ -791,20 +790,23 @@ public class RepositoryManager implements IRepositoryManager {
                if (r == null) {
                        return null;
                }
-               RepositoryModel model = new RepositoryModel();
-               model.isBare = r.isBare();
+
+               String name;
                File basePath = getRepositoriesFolder();
-               if (model.isBare) {
-                       model.name = com.gitblit.utils.FileUtils.getRelativePath(basePath, r.getDirectory());
+               if (r.isBare()) {
+                       name = com.gitblit.utils.FileUtils.getRelativePath(basePath, r.getDirectory());
                } else {
-                       model.name = com.gitblit.utils.FileUtils.getRelativePath(basePath, r.getDirectory().getParentFile());
+                       name = com.gitblit.utils.FileUtils.getRelativePath(basePath, r.getDirectory().getParentFile());
                }
-               if (StringUtils.isEmpty(model.name)) {
+
+               if (StringUtils.isEmpty(name)) {
                        // Repository is NOT located relative to the base folder because it
                        // is symlinked.  Use the provided repository name.
-                       model.name = repositoryName;
+                       name = repositoryName;
                }
-               model.projectPath = StringUtils.getFirstPathElement(repositoryName);
+
+               RepositoryModel model = new RepositoryModel(name);
+               model.isBare = r.isBare();
 
                StoredConfig config = r.getConfig();
                boolean hasOrigin = false;
@@ -823,7 +825,7 @@ public class RepositoryManager implements IRepositoryManager {
                        }
                        model.description = getConfig(config, "description", "");
                        model.originRepository = getConfig(config, "originRepository", null);
-                       model.addOwners(ArrayUtils.fromString(getConfig(config, "owner", "")));
+//                     model.addOwners(ArrayUtils.fromString(getConfig(config, "owner", "")));
                        model.acceptNewPatchsets = getConfig(config, "acceptNewPatchsets", true);
                        model.acceptNewTickets = getConfig(config, "acceptNewTickets", true);
                        model.requireApproval = getConfig(config, "requireApproval", settings.getBoolean(Keys.tickets.requireApproval, false));
@@ -968,10 +970,9 @@ public class RepositoryManager implements IRepositoryManager {
                if (StringUtils.isEmpty(origin)) {
                        return null;
                }
-               String userProject = ModelUtils.getPersonalPath(username);
+               String userPath = ModelUtils.getPersonalPath(username);
                if (settings.getBoolean(Keys.git.cacheRepositoryList, true)) {
                        String originKey = origin.toLowerCase();
-                       String userPath = userProject + "/";
 
                        // collect all origin nodes in fork network
                        Set<String> roots = new HashSet<String>();
@@ -1009,6 +1010,7 @@ public class RepositoryManager implements IRepositoryManager {
                        }
                } else {
                        // not caching
+                       String userProject = ModelUtils.getPersonalProject(username);
                        File subfolder = new File(getRepositoriesFolder(), userProject);
                        List<String> repositories = JGitUtils.getRepositoryList(subfolder,
                                        settings.getBoolean(Keys.git.onlyAccessBareRepositories, false),
@@ -1016,7 +1018,7 @@ public class RepositoryManager implements IRepositoryManager {
                                        settings.getInteger(Keys.git.searchRecursionDepth, -1),
                                        settings.getStrings(Keys.git.searchExclusions));
                        for (String repository : repositories) {
-                               RepositoryModel model = getRepositoryModel(userProject + "/" + repository);
+                               RepositoryModel model = getRepositoryModel(userPath + repository);
                                if (model.originRepository != null && model.originRepository.equalsIgnoreCase(origin)) {
                                        // user has a fork
                                        return model.name;
@@ -1450,7 +1452,7 @@ public class RepositoryManager implements IRepositoryManager {
                StoredConfig config = r.getConfig();
                config.setString(Constants.CONFIG_GITBLIT, null, "description", repository.description);
                config.setString(Constants.CONFIG_GITBLIT, null, "originRepository", repository.originRepository);
-               config.setString(Constants.CONFIG_GITBLIT, null, "owner", ArrayUtils.toString(repository.owners));
+//             config.setString(Constants.CONFIG_GITBLIT, null, "owner", ArrayUtils.toString(repository.owners));
                config.setBoolean(Constants.CONFIG_GITBLIT, null, "acceptNewPatchsets", repository.acceptNewPatchsets);
                config.setBoolean(Constants.CONFIG_GITBLIT, null, "acceptNewTickets", repository.acceptNewTickets);
                if (settings.getBoolean(Keys.tickets.requireApproval, false) == repository.requireApproval) {
index 2b82ffb63e6c06d0790121174c05ac20f20e39c8..617c81b4024833b0f69ecc0cb101c451e0f69c95 100644 (file)
@@ -33,6 +33,8 @@ import com.gitblit.IStoredSettings;
 import com.gitblit.IUserService;
 import com.gitblit.Keys;
 import com.gitblit.extensions.UserTeamLifeCycleListener;
+import com.gitblit.models.Owner;
+import com.gitblit.models.RepositoryModel;
 import com.gitblit.models.TeamModel;
 import com.gitblit.models.UserModel;
 import com.gitblit.utils.StringUtils;
@@ -491,6 +493,60 @@ public class UserManager implements IUserManager {
                return userService.deleteRepositoryRole(role);
        }
 
+       /**
+        * Returns the list of owners for the repository.
+        *
+        * @param repository
+        * @return a list of owners
+        */
+       @Override
+       public List<Owner> getOwners(RepositoryModel repository) {
+               List<Owner> list = new ArrayList<>();
+               for (UserModel user : getAllUsers()) {
+                       if (user.isOwner(repository)) {
+                               list.add(user);
+                       }
+               }
+               return list;
+       }
+
+       /**
+        * Set the repository owners.
+        *
+        * @param repository
+        * @param a list of owners
+        * @return true if successful
+        */
+       @Override
+       public boolean setOwners(RepositoryModel repository, List<Owner> owners) {
+               List<Owner> oldOwners = getOwners(repository);
+               List<UserModel> users = new ArrayList<>();
+
+               // identify new owners and filter-out continued owners
+               for (Owner owner : owners) {
+                       if (!oldOwners.remove(owner)) {
+                               // new owner
+                               owner.own(repository);
+                               if (owner instanceof UserModel) {
+                                       users.add((UserModel) owner);
+                               }
+                       }
+               }
+
+               // the remaining oldOwners are now former owners
+               for (Owner formerOwner : oldOwners) {
+                       formerOwner.disown(repository);
+
+                       if (formerOwner instanceof UserModel) {
+                               users.add((UserModel) formerOwner);
+                       }
+               }
+
+               updateUserModels(users);
+
+               return true;
+       }
+
        protected void callCreateUserListeners(UserModel user) {
                if (pluginManager == null || user == null) {
                        return;
diff --git a/src/main/java/com/gitblit/models/Owner.java b/src/main/java/com/gitblit/models/Owner.java
new file mode 100644 (file)
index 0000000..c05a596
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2014 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gitblit.models;
+
+import java.io.Serializable;
+import java.util.Set;
+import java.util.TreeSet;
+
+import com.gitblit.utils.StringUtils;
+
+/**
+ * The owner class defines the ownership method contract for an object.
+ *
+ * @author James Moger
+ *
+ */
+public abstract class Owner implements Serializable {
+
+       private static final long serialVersionUID = 1L;
+
+       public final Set<String> ownedPaths = new TreeSet<String>();
+
+       public abstract String getId();
+
+       public abstract String getDisplayName();
+
+       public abstract String getPersonalPath();
+
+       public boolean isOwner(String path) {
+               if (StringUtils.isEmpty(path)) {
+                       return false;
+               }
+
+               String personalPath = getPersonalPath();
+               if (personalPath != null && path.startsWith(personalPath)) {
+                       return true;
+               }
+
+               if (ownedPaths == null) {
+                       return false;
+               }
+
+               if (ownedPaths.contains(path.toLowerCase())) {
+                       // exact path match
+                       return true;
+               }
+
+               for (String ownedPath : ownedPaths) {
+                       if (StringUtils.matchesIgnoreCase(path, ownedPath)) {
+                               // regex match
+                               return true;
+                       }
+               }
+
+               return false;
+       }
+
+       public void own(String path) {
+               ownedPaths.add(path.toLowerCase());
+       }
+
+       public void disown(String path) {
+               ownedPaths.remove(path.toLowerCase());
+       }
+
+       public boolean isOwner(RepositoryModel repository) {
+               return isOwner(repository.name);
+       }
+
+       public void own(RepositoryModel repository) {
+               own(repository.name);
+       }
+
+       public void disown(RepositoryModel repository) {
+               disown(repository.name);
+       }
+}
index a81c622af4d35f0d319b2802429e7447ea2aaad4..78e9728b0e2ef3f9bd157fb1b415644db7291f3c 100644 (file)
@@ -17,7 +17,6 @@ package com.gitblit.models;
 \r
 import java.io.Serializable;\r
 import java.util.ArrayList;\r
-import java.util.Collection;\r
 import java.util.Date;\r
 import java.util.List;\r
 import java.util.Map;\r
@@ -46,7 +45,6 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
        // field names are reflectively mapped in EditRepository page\r
        public String name;\r
        public String description;\r
-       public List<String> owners;\r
        public Date lastChange;\r
        public String lastChangeAuthor;\r
        public boolean hasCommits;\r
@@ -74,7 +72,7 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
        public List<String> postReceiveScripts;\r
        public List<String> mailingLists;\r
        public Map<String, String> customFields;\r
-       public String projectPath;\r
+       private String projectPath;\r
        private String displayName;\r
        public boolean allowForks;\r
        public Set<String> forks;\r
@@ -95,11 +93,17 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
        public String sparkleshareId;\r
 \r
        public RepositoryModel() {\r
-               this("", "", "", new Date(0));\r
+               this("", "", new Date(0));\r
        }\r
 \r
-       public RepositoryModel(String name, String description, String owner, Date lastchange) {\r
+       public RepositoryModel(String name ) {\r
                this.name = name;\r
+               this.projectPath = StringUtils.getFirstPathElement(name);\r
+       }\r
+\r
+       public RepositoryModel(String name, String description, Date lastchange) {\r
+               this.name = name;\r
+               this.projectPath = StringUtils.getFirstPathElement(name);\r
                this.description = description;\r
                this.lastChange = lastchange;\r
                this.accessRestriction = AccessRestrictionType.NONE;\r
@@ -107,12 +111,9 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
                this.federationSets = new ArrayList<String>();\r
                this.federationStrategy = FederationStrategy.FEDERATE_THIS;\r
                this.projectPath = StringUtils.getFirstPathElement(name);\r
-               this.owners = new ArrayList<String>();\r
                this.isBare = true;\r
                this.acceptNewTickets = true;\r
                this.acceptNewPatchsets = true;\r
-\r
-               addOwner(owner);\r
        }\r
 \r
        public List<String> getLocalBranches() {\r
@@ -180,19 +181,31 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
                return !StringUtils.isEmpty(originRepository);\r
        }\r
 \r
-       public boolean isOwner(String username) {\r
-               if (StringUtils.isEmpty(username) || ArrayUtils.isEmpty(owners)) {\r
-                       return isUsersPersonalRepository(username);\r
-               }\r
-               return owners.contains(username.toLowerCase()) || isUsersPersonalRepository(username);\r
-       }\r
-\r
        public boolean isPersonalRepository() {\r
                return !StringUtils.isEmpty(projectPath) && ModelUtils.isPersonalRepository(projectPath);\r
        }\r
 \r
-       public boolean isUsersPersonalRepository(String username) {\r
-               return !StringUtils.isEmpty(projectPath) && ModelUtils.isUsersPersonalRepository(username, projectPath);\r
+       public String getPersonalRepositoryOwner() {\r
+               return ModelUtils.getUserNameFromRepoPath(projectPath);\r
+       }\r
+\r
+       /**\r
+        * Returns the project name.\r
+        *\r
+        * @return project name\r
+        */\r
+       public String getProject() {\r
+               return projectPath;\r
+       }\r
+\r
+       /**\r
+        * Returns the first path element of the full repository path.  This path will always end with\r
+        * a trailing '/'.\r
+        *\r
+        * @return the project path of the repository\r
+        */\r
+       public String getProjectPath() {\r
+               return StringUtils.isEmpty(projectPath) ? "/" : (projectPath + "/");\r
        }\r
 \r
        public boolean allowAnonymousView() {\r
@@ -226,37 +239,4 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
                clone.sparkleshareId = sparkleshareId;\r
                return clone;\r
        }\r
-\r
-       public void addOwner(String username) {\r
-               if (!StringUtils.isEmpty(username)) {\r
-                       String name = username.toLowerCase();\r
-                       // a set would be more efficient, but this complicates JSON\r
-                       // deserialization so we enforce uniqueness with an arraylist\r
-                       if (!owners.contains(name)) {\r
-                               owners.add(name);\r
-                       }\r
-               }\r
-       }\r
-\r
-       public void removeOwner(String username) {\r
-               if (!StringUtils.isEmpty(username)) {\r
-                       owners.remove(username.toLowerCase());\r
-               }\r
-       }\r
-\r
-       public void addOwners(Collection<String> usernames) {\r
-               if (!ArrayUtils.isEmpty(usernames)) {\r
-                       for (String username : usernames) {\r
-                               addOwner(username);\r
-                       }\r
-               }\r
-       }\r
-\r
-       public void removeOwners(Collection<String> usernames) {\r
-               if (!ArrayUtils.isEmpty(owners)) {\r
-                       for (String username : usernames) {\r
-                               removeOwner(username);\r
-                       }\r
-               }\r
-       }\r
 }
index e15227482f2ea9d99cc186c502fa216bf2b0f73a..a70f852453db37acb225725af46f4b4a84cd6a66 100644 (file)
@@ -46,7 +46,7 @@ import com.gitblit.utils.StringUtils;
  * @author James Moger\r
  *\r
  */\r
-public class UserModel implements Principal, Serializable, Comparable<UserModel> {\r
+public class UserModel extends Owner implements Principal, Serializable, Comparable<UserModel> {\r
 \r
        private static final long serialVersionUID = 1L;\r
 \r
@@ -94,6 +94,11 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
                this.userPreferences = new UserPreferences(this.username);\r
        }\r
 \r
+       @Override\r
+       public String getId() {\r
+               return username;\r
+       }\r
+\r
        public boolean isLocalAccount() {\r
                return !Constants.EXTERNAL_ACCOUNT.equals(password)\r
                                || accountType == null\r
@@ -279,7 +284,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
                }\r
 \r
                // repository owner - either specified owner or personal repository\r
-               if (repository.isOwner(username) || repository.isUsersPersonalRepository(username)) {\r
+               if (isOwner(repository)) {\r
                        ap.permissionType = PermissionType.OWNER;\r
                        if (AccessPermission.REWIND.atMost(maxPermission)) {\r
                                ap.permission = AccessPermission.REWIND;\r
@@ -423,11 +428,11 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
        }\r
 \r
        public boolean canFork(RepositoryModel repository) {\r
-               if (repository.isUsersPersonalRepository(username)) {\r
+               if (isMyPersonalRepository(repository.name)) {\r
                        // can not fork your own repository\r
                        return false;\r
                }\r
-               if (canAdmin() || repository.isOwner(username)) {\r
+               if (canAdmin() || isOwner(repository)) {\r
                        return true;\r
                }\r
                if (!repository.allowForks) {\r
@@ -440,11 +445,13 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
        }\r
 \r
        public boolean canDelete(RepositoryModel model) {\r
-               return canAdmin() || model.isUsersPersonalRepository(username);\r
+               return canAdmin()\r
+                               || isMyPersonalRepository(model.name)\r
+                               || (!model.isPersonalRepository() && isOwner(model));\r
        }\r
 \r
        public boolean canEdit(RepositoryModel model) {\r
-               return canAdmin() || model.isUsersPersonalRepository(username) || model.isOwner(username);\r
+               return canAdmin() || isOwner(model);\r
        }\r
 \r
        public boolean canEdit(TicketModel ticket, RepositoryModel repository) {\r
@@ -544,15 +551,22 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
                        return true;\r
                }\r
                if (canCreate()) {\r
-                       String projectPath = StringUtils.getFirstPathElement(repository);\r
-                       if (!StringUtils.isEmpty(projectPath) && projectPath.equalsIgnoreCase(getPersonalPath())) {\r
-                               // personal repository\r
-                               return true;\r
-                       }\r
+                       String projectPath = StringUtils.getFirstPathElement(repository) + "/";\r
+                       return isOwner(projectPath);\r
                }\r
                return false;\r
        }\r
 \r
+//     /**\r
+//      * Returns true if the user is allowed to administer the specified project\r
+//      *\r
+//      * @param project\r
+//      * @return true if the user can administer the project\r
+//      */\r
+//     public boolean canAdmin(ProjectModel project) {\r
+//             return canAdmin() || isOwner(project);\r
+//     }\r
+//\r
        /**\r
         * Returns true if the user is allowed to administer the specified repository\r
         *\r
@@ -560,7 +574,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
         * @return true if the user can administer the repository\r
         */\r
        public boolean canAdmin(RepositoryModel repo) {\r
-               return canAdmin() || repo.isOwner(username) || isMyPersonalRepository(repo.name);\r
+               return canAdmin() || isOwner(repo);\r
        }\r
 \r
        public boolean isAuthenticated() {\r
@@ -593,6 +607,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
                return username;\r
        }\r
 \r
+       @Override\r
        public String getDisplayName() {\r
                if (StringUtils.isEmpty(displayName)) {\r
                        return username;\r
@@ -600,6 +615,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
                return displayName;\r
        }\r
 \r
+       @Override\r
        public String getPersonalPath() {\r
                return ModelUtils.getPersonalPath(username);\r
        }\r
@@ -657,7 +673,31 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
        }\r
 \r
        public boolean isMyPersonalRepository(String repository) {\r
-               String projectPath = StringUtils.getFirstPathElement(repository);\r
-               return !StringUtils.isEmpty(projectPath) && projectPath.equalsIgnoreCase(getPersonalPath());\r
+               return repository.startsWith(getPersonalPath());\r
        }\r
+\r
+       @Override\r
+       public boolean isOwner(RepositoryModel repository) {\r
+               return isMyPersonalRepository(repository.name)\r
+                               || isOwner(repository.name);\r
+       }\r
+//     public boolean isOwner(ProjectModel project) {\r
+//     return isOwner(project.name + "/");\r
+//}\r
+//\r
+//     public void own(ProjectModel project) {\r
+//             if (StringUtils.isEmpty(project.name)) {\r
+//                     own("/");\r
+//             } else {\r
+//                     own(project.name.toLowerCase() + "/");\r
+//             }\r
+//     }\r
+//\r
+//     public void disown(ProjectModel project) {\r
+//             if (StringUtils.isEmpty(project.name)) {\r
+//                     disown("/");\r
+//             } else {\r
+//                     disown(project.name.toLowerCase() + "/");\r
+//             }\r
+//     }\r
 }\r
index bb3d3216e9559260e8a5dce658fde612001b72c3..d9c1c08e4b26f80d9ffdf85ef86564fdf93c960a 100644 (file)
@@ -26,6 +26,7 @@ import com.gitblit.GitBlitException;
 import com.gitblit.IStoredSettings;\r
 import com.gitblit.Keys;\r
 import com.gitblit.manager.IFederationManager;\r
+import com.gitblit.manager.IUserManager;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.UserModel;\r
 import com.gitblit.utils.StringUtils;\r
@@ -51,12 +52,15 @@ public class GitFilter extends AccessRestrictionFilter {
 \r
        private IStoredSettings settings;\r
 \r
+       private IUserManager userManager;\r
+\r
        private IFederationManager federationManager;\r
 \r
        @Override\r
        protected void inject(ObjectGraph dagger, FilterConfig filterConfig) {\r
                super.inject(dagger, filterConfig);\r
                this.settings = dagger.get(IStoredSettings.class);\r
+               this.userManager = dagger.get(IUserManager.class);\r
                this.federationManager = dagger.get(IFederationManager.class);\r
        }\r
 \r
@@ -241,11 +245,8 @@ public class GitFilter extends AccessRestrictionFilter {
                                }\r
 \r
                                // create repository\r
-                               RepositoryModel model = new RepositoryModel();\r
-                               model.name = repository;\r
-                               model.addOwner(user.username);\r
-                               model.projectPath = StringUtils.getFirstPathElement(repository);\r
-                               if (model.isUsersPersonalRepository(user.username)) {\r
+                               RepositoryModel model = new RepositoryModel(repository);\r
+                               if (user.isMyPersonalRepository(model.name)) {\r
                                        // personal repository, default to private for user\r
                                        model.authorizationControl = AuthorizationControl.NAMED;\r
                                        model.accessRestriction = AccessRestrictionType.VIEW;\r
@@ -258,6 +259,8 @@ public class GitFilter extends AccessRestrictionFilter {
                                // create the repository\r
                                try {\r
                                        repositoryManager.updateRepositoryModel(model.name, model, true);\r
+                                       user.own(model);\r
+                                       userManager.updateUserModel(user.username, user);\r
                                        logger.info(MessageFormat.format("{0} created {1} ON-PUSH", user.username, model.name));\r
                                        return repositoryManager.getRepositoryModel(model.name);\r
                                } catch (GitBlitException e) {\r
index b8cdfb04794adbb3874fb03fd67fafe8b021bf89..e09e921a9b859bf2283e975be8325808028a1e4a 100644 (file)
@@ -38,6 +38,7 @@ import com.gitblit.manager.IGitblit;
 import com.gitblit.models.RefModel;\r
 import com.gitblit.models.RegistrantAccessPermission;\r
 import com.gitblit.models.RepositoryModel;\r
+import com.gitblit.models.Owner;\r
 import com.gitblit.models.ServerSettings;\r
 import com.gitblit.models.TeamModel;\r
 import com.gitblit.models.UserModel;\r
@@ -300,6 +301,29 @@ public class RpcServlet extends JsonServlet {
                } else if (RpcRequest.SET_REPOSITORY_MEMBERS.equals(reqType)) {\r
                        // rejected since 1.2.0\r
                        response.setStatus(failureCode);\r
+               } else if (RpcRequest.LIST_REPOSITORY_OWNERS.equals(reqType)) {\r
+                       // get repository owners\r
+                       RepositoryModel model = gitblit.getRepositoryModel(objectName);\r
+                       List<Owner> owners = gitblit.getOwners(model);\r
+                       List<String> names = new ArrayList<>();\r
+                       for (Owner owner : owners) {\r
+                               if (owner instanceof UserModel) {\r
+                                       names.add(((UserModel) owner).username);\r
+                               }\r
+                       }\r
+                       result = names;\r
+               } else if (RpcRequest.SET_REPOSITORY_OWNERS.equals(reqType)) {\r
+                       // set the owners for the specified repository\r
+                       RepositoryModel model = gitblit.getRepositoryModel(objectName);\r
+                       Collection<String> names = deserialize(request, response, RpcUtils.NAMES_TYPE);\r
+                       List<Owner> owners = new ArrayList<>();\r
+                       for (String name : names) {\r
+                               UserModel owner = gitblit.getUserModel(name);\r
+                               if (owner != null) {\r
+                                       owners.add(owner);\r
+                               }\r
+                       }\r
+                       result = gitblit.setOwners(model, owners);\r
                } else if (RpcRequest.LIST_REPOSITORY_MEMBER_PERMISSIONS.equals(reqType)) {\r
                        // get repository member permissions\r
                        RepositoryModel model = gitblit.getRepositoryModel(objectName);\r
index 8c000550a00eb7edc8d71c5d34c70eb6fbabc28a..448014f7d80d005a8eeb9b8018865364512ff327 100644 (file)
@@ -494,7 +494,7 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi
                                                continue;
                                        }
                                        TicketModel ticket = TicketModel.buildTicket(changes);
-                                       ticket.project = repository.projectPath;
+                                       ticket.project = repository.getProject();
                                        ticket.repository = repository.name;
                                        ticket.number = ticketId;
 
@@ -540,7 +540,7 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi
                        }
                        TicketModel ticket = TicketModel.buildTicket(changes);
                        if (ticket != null) {
-                               ticket.project = repository.projectPath;
+                               ticket.project = repository.getProject();
                                ticket.repository = repository.name;
                                ticket.number = ticketId;
                        }
index b3d8838ec899c6d1dd14a69eda1f626c6af90c30..33b5307b41b3fdc8356639a9183609c4bd0a2da5 100644 (file)
@@ -257,7 +257,7 @@ public class FileTicketService extends ITicketService {
                                                continue;
                                        }
                                        TicketModel ticket = TicketModel.buildTicket(changes);
-                                       ticket.project = repository.projectPath;
+                                       ticket.project = repository.getProject();
                                        ticket.repository = repository.name;
                                        ticket.number = ticketId;
 
@@ -320,7 +320,7 @@ public class FileTicketService extends ITicketService {
                        }
                        TicketModel ticket = TicketModel.buildTicket(changes);
                        if (ticket != null) {
-                               ticket.project = repository.projectPath;
+                               ticket.project = repository.getProject();
                                ticket.repository = repository.name;
                                ticket.number = ticketId;
                        }
index d773b0bd38e7651068bbc4bc94b64daa7fd1639d..465bda31ba841b250ced779107dcbbb4be886747 100644 (file)
@@ -276,7 +276,7 @@ public class RedisTicketService extends ITicketService {
                                        continue;
                                }
                                TicketModel ticket = TicketModel.buildTicket(changes);
-                               ticket.project = repository.projectPath;
+                               ticket.project = repository.getProject();
                                ticket.repository = repository.name;
                                ticket.number = ticketId;
 
@@ -325,7 +325,7 @@ public class RedisTicketService extends ITicketService {
                                return null;
                        }
                        TicketModel ticket = TicketModel.buildTicket(changes);
-                       ticket.project = repository.projectPath;
+                       ticket.project = repository.getProject();
                        ticket.repository = repository.name;
                        ticket.number = ticketId;
                        log.debug("rebuilt ticket {} from Redis @ {}", ticketId, getUrl());
index 07371b1b0591768941ca027c2957eb315e046459..d4307106e5b6a331366ac6950764965ddb975f0d 100644 (file)
@@ -49,6 +49,7 @@ import com.gitblit.manager.IRepositoryManager;
 import com.gitblit.manager.IRuntimeManager;
 import com.gitblit.manager.IUserManager;
 import com.gitblit.models.Mailing;
+import com.gitblit.models.Owner;
 import com.gitblit.models.PathModel.PathChangeModel;
 import com.gitblit.models.RepositoryModel;
 import com.gitblit.models.TicketModel;
@@ -551,11 +552,6 @@ public class TicketNotifier {
                //
                Set<String> ccs = new TreeSet<String>();
 
-               // repository owners
-               if (!ArrayUtils.isEmpty(repository.owners)) {
-                       ccs.addAll(repository.owners);
-               }
-
                // cc users mentioned in last comment
                Change lastChange = ticket.changes.get(ticket.changes.size() - 1);
                if (lastChange.hasComment()) {
@@ -573,6 +569,7 @@ public class TicketNotifier {
                // TODO cc users who are watching the repository
 
                Set<String> ccAddresses = new TreeSet<String>();
+
                for (String name : ccs) {
                        UserModel user = userManager.getUserModel(name);
                        if (user != null && !user.disabled) {
@@ -588,6 +585,16 @@ public class TicketNotifier {
                        }
                }
 
+               // repository owners
+               for (Owner owner : userManager.getOwners(repository)) {
+                       if (owner instanceof UserModel) {
+                               UserModel user = (UserModel) owner;
+                               if (!StringUtils.isEmpty(user.emailAddress)) {
+                                       ccAddresses.add(user.emailAddress);
+                               }
+                       }
+               }
+
                // cc repository mailing list addresses
                if (!ArrayUtils.isEmpty(repository.mailingLists)) {
                        ccAddresses.addAll(repository.mailingLists);
index 6fb4c0ac68472ac5161cfd3325117d4ea133f0e2..74e97abbde25248dffeafb7ee33decb09dc1100b 100644 (file)
@@ -56,6 +56,16 @@ public class ModelUtils
                return userRepoPrefix;
        }
 
+       /**
+        * Get the user project name for a user.
+        *
+        * @param username name of user
+        * @return the active user repository project prefix concatenated with the user name
+        */
+       public static String getPersonalProject(String username)
+       {
+               return userRepoPrefix + username.toLowerCase();
+       }
 
        /**
         * Get the user project name for a user.
@@ -65,7 +75,7 @@ public class ModelUtils
         */
        public static String getPersonalPath(String username)
        {
-               return userRepoPrefix + username.toLowerCase();
+               return userRepoPrefix + username.toLowerCase() + "/";
        }
 
 
index 82202154a5d157ac8b42e7ed65aa31b8d7456c7d..21841acc09e6fa33eb67503122f4516862287413 100644 (file)
@@ -460,6 +460,41 @@ public class RpcUtils {
                                account, password);\r
        }\r
 \r
+       /**\r
+        * Retrieves the list of owners for the specified repository.\r
+        *\r
+        * @param repository\r
+        * @param serverUrl\r
+        * @param account\r
+        * @param password\r
+        * @return list of owners\r
+        * @throws IOException\r
+        */\r
+       public static List<String> getRepositoryOwners(RepositoryModel repository,\r
+                       String serverUrl, String account, char [] password) throws IOException {\r
+               String url = asLink(serverUrl, RpcRequest.LIST_REPOSITORY_OWNERS, repository.name);\r
+               Collection<String> list = JsonUtils.retrieveJson(url, NAMES_TYPE, account, password);\r
+               return new ArrayList<String>(list);\r
+       }\r
+\r
+       /**\r
+        * Sets the repository owners\r
+        *\r
+        * @param repository\r
+        * @param owners\r
+        * @param serverUrl\r
+        * @param account\r
+        * @param password\r
+        * @return true if the action succeeded\r
+        * @throws IOException\r
+        */\r
+       public static boolean setRepositoryOwners(RepositoryModel repository,\r
+                       List<String> owners, String serverUrl, String account, char[] password)\r
+                       throws IOException {\r
+               return doAction(RpcRequest.SET_REPOSITORY_OWNERS, repository.name, owners, serverUrl,\r
+                               account, password);\r
+       }\r
+\r
        /**\r
         * Retrieves the list of teams that can access the specified repository.\r
         *\r
index a1c373851d7f70a071b55c3d952a0fedcce3aa11..85ee55fc0087fc6f10efdec3078232570df8578b 100644 (file)
@@ -59,6 +59,7 @@ import com.gitblit.Constants.FederationStrategy;
 import com.gitblit.Constants.RegistrantType;\r
 import com.gitblit.GitBlitException;\r
 import com.gitblit.Keys;\r
+import com.gitblit.models.Owner;\r
 import com.gitblit.models.RegistrantAccessPermission;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.UserChoice;\r
@@ -107,9 +108,8 @@ public class EditRepositoryPage extends RootSubPage {
                UserModel user = session.getUser();\r
                if (user != null && user.canCreate() && !user.canAdmin()) {\r
                        // personal create permissions, inject personal repository path\r
-                       model.name = user.getPersonalPath() + "/";\r
-                       model.projectPath = user.getPersonalPath();\r
-                       model.addOwner(user.username);\r
+                       model.name = user.getPersonalPath();\r
+\r
                        // personal repositories are private by default\r
                        model.accessRestriction = AccessRestrictionType.VIEW;\r
                        model.authorizationControl = AuthorizationControl.NAMED;\r
@@ -156,7 +156,6 @@ public class EditRepositoryPage extends RootSubPage {
 \r
                GitBlitWebSession session = GitBlitWebSession.get();\r
                final UserModel user = session.getUser() == null ? UserModel.ANONYMOUS : session.getUser();\r
-               final boolean allowEditName = isCreate || isAdmin || repositoryModel.isUsersPersonalRepository(user.username);\r
 \r
                if (isCreate) {\r
                        if (user.canAdmin()) {\r
@@ -186,12 +185,10 @@ public class EditRepositoryPage extends RootSubPage {
 \r
                // owners palette\r
                List<UserChoice> owners = new ArrayList<UserChoice>();\r
-               for (String owner : repositoryModel.owners) {\r
-                       UserModel o = app().users().getUserModel(owner);\r
-                       if (o != null) {\r
-                               owners.add(new UserChoice(o.getDisplayName(), o.username, o.emailAddress));\r
-                       } else {\r
-                               owners.add(new UserChoice(owner));\r
+               for (Owner owner : app().users().getOwners(repositoryModel)) {\r
+                       if (owner instanceof UserModel) {\r
+                               UserModel userOwner = (UserModel) owner;\r
+                               owners.add(new UserChoice(userOwner.getDisplayName(), userOwner.username, userOwner.emailAddress));\r
                        }\r
                }\r
                List<UserChoice> persons = new ArrayList<UserChoice>();\r
@@ -338,13 +335,6 @@ public class EditRepositoryPage extends RootSubPage {
                                        }\r
                                        repositoryModel.indexedBranches = indexedBranches;\r
 \r
-                                       // owners\r
-                                       repositoryModel.owners.clear();\r
-                                       Iterator<UserChoice> owners = ownersPalette.getSelectedChoices();\r
-                                       while (owners.hasNext()) {\r
-                                               repositoryModel.addOwner(owners.next().getUserId());\r
-                                       }\r
-\r
                                        // pre-receive scripts\r
                                        List<String> preReceiveScripts = new ArrayList<String>();\r
                                        Iterator<String> pres = preReceivePalette.getSelectedChoices();\r
@@ -381,6 +371,21 @@ public class EditRepositoryPage extends RootSubPage {
                                                app().gitblit().setUserAccessPermissions(repositoryModel, repositoryUsers);\r
                                                app().gitblit().setTeamAccessPermissions(repositoryModel, repositoryTeams);\r
                                        }\r
+\r
+                                       //\r
+                                       // handle ownership changes\r
+                                       //\r
+\r
+                                       List<Owner> newOwners = new ArrayList<>();\r
+                                       Iterator<UserChoice> owners = ownersPalette.getSelectedChoices();\r
+                                       while (owners.hasNext()) {\r
+                                               String username = owners.next().getUserId();\r
+                                               UserModel owner = app().users().getUserModel(username);\r
+                                               newOwners.add(owner);\r
+                                       }\r
+\r
+                                       app().users().setOwners(repositoryModel, newOwners);\r
+\r
                                } catch (GitBlitException e) {\r
                                        error(e.getMessage());\r
                                        return;\r
@@ -413,7 +418,6 @@ public class EditRepositoryPage extends RootSubPage {
                // GENERAL\r
                //\r
                namePanel = new RepositoryNamePanel("namePanel", repositoryModel);\r
-               namePanel.setEditable(allowEditName);\r
                form.add(namePanel);\r
 \r
                // XXX AccessPolicyPanel is defined later.\r
@@ -667,7 +671,7 @@ public class EditRepositoryPage extends RootSubPage {
                // the user can delete if deletions are allowed AND the user is an admin or the personal owner\r
                // assigned ownership is not sufficient to allow deletion\r
                boolean canDelete = !isCreate && app().repositories().canDelete(repositoryModel)\r
-                               && (user.canAdmin() || user.isMyPersonalRepository(repositoryModel.name));\r
+                               && user.canDelete(repositoryModel);\r
 \r
                Link<Void> delete = new Link<Void>("delete") {\r
 \r
@@ -682,8 +686,7 @@ public class EditRepositoryPage extends RootSubPage {
                                                info(MessageFormat.format(getString("gb.repositoryDeleted"), latestModel));\r
                                                if (latestModel.isPersonalRepository()) {\r
                                                        // redirect to user's profile page\r
-                                                       String prefix = app().settings().getString(Keys.git.userRepositoryPrefix, "~");\r
-                                                       String username = latestModel.projectPath.substring(prefix.length());\r
+                                                       String username = latestModel.getPersonalRepositoryOwner();\r
                                                        setResponsePage(UserPage.class, WicketUtils.newUsernameParameter(username));\r
                                                } else {\r
                                                        // redirect to server repositories page\r
@@ -740,7 +743,7 @@ public class EditRepositoryPage extends RootSubPage {
                                                isAdmin = true;\r
                                                return;\r
                                        } else {\r
-                                               if (!model.isOwner(user.username)) {\r
+                                               if (!user.isOwner(model)) {\r
                                                        // User is not an Admin nor Owner\r
                                                        error(getString("gb.errorOnlyAdminOrOwnerMayEditRepository"), true);\r
                                                }\r
index 9fd7f4db7f36538d53a51fc48503f1559f50353d..1c113c3b98f3bf849f73a7436889ad590bc5748f 100644 (file)
@@ -31,6 +31,7 @@ import com.gitblit.Keys;
 import com.gitblit.models.ForkModel;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.UserModel;\r
+import com.gitblit.utils.ModelUtils;\r
 import com.gitblit.utils.StringUtils;\r
 import com.gitblit.wicket.GitBlitWebSession;\r
 import com.gitblit.wicket.WicketUtils;\r
@@ -57,10 +58,11 @@ public class ForksPage extends RepositoryPage {
                                RepositoryModel repository = fork.repository;\r
 \r
                                if (repository.isPersonalRepository()) {\r
-                                       UserModel user = app().users().getUserModel(repository.projectPath.substring(1));\r
+                                       String name = ModelUtils.getUserNameFromRepoPath(repository.name);\r
+                                       UserModel user = app().users().getUserModel(name);\r
                                        if (user == null) {\r
                                                // user account no longer exists\r
-                                               user = new UserModel(repository.projectPath.substring(1));\r
+                                               user = new UserModel(name);\r
                                        }\r
                                        PersonIdent ident = new PersonIdent(user.getDisplayName(), user.emailAddress == null ? user.getDisplayName() : user.emailAddress);\r
                                        item.add(new GravatarImage("anAvatar", ident, 20));\r
@@ -81,7 +83,7 @@ public class ForksPage extends RepositoryPage {
                                        WicketUtils.setCssClass(swatch,  "repositorySwatch");\r
                                        WicketUtils.setCssBackground(swatch, repository.toString());\r
                                        item.add(swatch);\r
-                                       String projectName = repository.projectPath;\r
+                                       String projectName = repository.getProject();\r
                                        if (StringUtils.isEmpty(projectName)) {\r
                                                projectName = app().settings().getString(Keys.web.repositoryRootGroupName, "main");\r
                                        }\r
index 0f7d602bbf3886116665fb643a1092aaa7b6b3c4..d7d522c7950a687c22629042d4cab0ebfbd51ce1 100644 (file)
@@ -112,7 +112,7 @@ public class MyDashboardPage extends DashboardPage {
                List<RepositoryModel> active = new ArrayList<RepositoryModel>();\r
 \r
                for (RepositoryModel model : getRepositoryModels()) {\r
-                       if (model.isUsersPersonalRepository(user.username) || model.isOwner(user.username)) {\r
+                       if (user.isOwner(model)) {\r
                                owned.add(model);\r
                        }\r
 \r
index 4687716831bcf7590de4b9e6cc88279f8ceb8652..b4c2f664bf5718444317bdff37660116e566c1c9 100644 (file)
@@ -19,6 +19,7 @@ import java.io.File;
 import java.io.IOException;\r
 import java.io.UnsupportedEncodingException;\r
 import java.util.ArrayList;\r
+import java.util.Arrays;\r
 import java.util.Collections;\r
 import java.util.List;\r
 \r
@@ -48,6 +49,7 @@ import com.gitblit.Constants.AccessRestrictionType;
 import com.gitblit.Constants.AuthorizationControl;\r
 import com.gitblit.GitBlitException;\r
 import com.gitblit.Keys;\r
+import com.gitblit.models.Owner;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.UserModel;\r
 import com.gitblit.utils.ArrayUtils;\r
@@ -108,9 +110,6 @@ public class NewRepositoryPage extends RootSubPage {
                                        }\r
                                        accessPolicyPanel.updateModel(repositoryModel);\r
 \r
-                                       repositoryModel.owners = new ArrayList<String>();\r
-                                       repositoryModel.owners.add(GitBlitWebSession.get().getUsername());\r
-\r
                                        // setup branch defaults\r
                                        boolean useGitFlow = addGitflowModel.getObject();\r
 \r
@@ -137,6 +136,10 @@ public class NewRepositoryPage extends RootSubPage {
                                        // init the repository\r
                                        app().gitblit().updateRepositoryModel(repositoryModel.name, repositoryModel, true);\r
 \r
+                                       // save the owner change\r
+                                       List<Owner> owners = Arrays.asList((Owner) GitBlitWebSession.get().getUser());\r
+                                       app().gitblit().setOwners(repositoryModel, owners);\r
+\r
                                        // optionally create an initial commit\r
                                        initialCommit(repositoryModel, addReadme, gitignore, useGitFlow);\r
 \r
index 1979f97f3daa6dc590a5c5da20c0ba2ea3a46df7..e70d3b1579c460b3e0c3012ba4d648a11ece8b8b 100644 (file)
@@ -16,7 +16,6 @@
 package com.gitblit.wicket.pages;\r
 \r
 import java.text.MessageFormat;\r
-import java.util.ArrayList;\r
 import java.util.List;\r
 \r
 import org.apache.wicket.PageParameters;\r
@@ -30,6 +29,7 @@ import org.eclipse.jgit.lib.Repository;
 \r
 import com.gitblit.Keys;\r
 import com.gitblit.models.Metric;\r
+import com.gitblit.models.Owner;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.UserModel;\r
 import com.gitblit.utils.JGitUtils;\r
@@ -74,23 +74,18 @@ public class OverviewPage extends RepositoryPage {
                add(new Label("repositoryDescription", getRepositoryModel().description));\r
 \r
                // owner links\r
-               final List<String> owners = new ArrayList<String>(getRepositoryModel().owners);\r
-               ListDataProvider<String> ownersDp = new ListDataProvider<String>(owners);\r
-               DataView<String> ownersView = new DataView<String>("repositoryOwners", ownersDp) {\r
+               final List<Owner> owners = app().users().getOwners(getRepositoryModel());\r
+               ListDataProvider<Owner> ownersDp = new ListDataProvider<Owner>(owners);\r
+               DataView<Owner> ownersView = new DataView<Owner>("repositoryOwners", ownersDp) {\r
                        private static final long serialVersionUID = 1L;\r
                        int counter = 0;\r
                        @Override\r
-                       public void populateItem(final Item<String> item) {\r
-                               String ownername = item.getModelObject();\r
-                               UserModel ownerModel = app().users().getUserModel(ownername);\r
-                               if (ownerModel != null) {\r
-                                       item.add(new LinkPanel("owner", null, ownerModel.getDisplayName(), UserPage.class,\r
-                                                       WicketUtils.newUsernameParameter(ownerModel.username)).setRenderBodyOnly(true));\r
-                               } else {\r
-                                       Label owner = new Label("owner", ownername);\r
-                                       WicketUtils.setCssStyle(owner, "text-decoration: line-through;");\r
-                                       WicketUtils.setHtmlTooltip(owner,  MessageFormat.format(getString("gb.failedToFindAccount"), ownername));\r
-                                       item.add(owner);\r
+                       public void populateItem(final Item<Owner> item) {\r
+                               Owner owner = item.getModelObject();\r
+                               if (owner instanceof UserModel) {\r
+                                       UserModel user = (UserModel) owner;\r
+                                       item.add(new LinkPanel("owner", null, user.getDisplayName(), UserPage.class,\r
+                                               WicketUtils.newUsernameParameter(user.username)).setRenderBodyOnly(true));\r
                                }\r
                                counter++;\r
                                item.add(new Label("comma", ",").setVisible(counter < owners.size()));\r
@@ -136,7 +131,7 @@ public class OverviewPage extends RepositoryPage {
                                && app().settings().getBoolean(Keys.web.generateActivityGraph, true)) {\r
 \r
                        Charts charts = new Flotr2Charts();\r
-                       \r
+\r
                        // daily line chart\r
                        Chart chart = charts.createLineChart("chartDaily", "", "unit",\r
                                        getString("gb.commits"));\r
index fcf659af2ee4b0cbc08877230eaa31ed38facdef..71eb859ec72cce19588441720ea6427dfdbb25f4 100644 (file)
@@ -156,7 +156,7 @@ public abstract class RepositoryPage extends RootPage {
                        showAdmin = app().settings().getBoolean(Keys.web.allowAdministration, false);\r
                }\r
                isOwner = GitBlitWebSession.get().isLoggedIn()\r
-                               && (getRepositoryModel().isOwner(GitBlitWebSession.get().getUsername()));\r
+                               && (GitBlitWebSession.get().getUser().isOwner(getRepositoryModel()));\r
 \r
                // register the available navigation links for this page and user\r
                List<NavLink> navLinks = registerNavLinks();\r
index b1c3639dfc68d83d522f6d0cd3d24511cab647dc..98a8df89761ad53bc0d671f6b64c11b9ba9ae8fe 100644 (file)
@@ -412,7 +412,7 @@ public abstract class RootPage extends BasePage {
                String userName = WicketUtils.getUsername(params);
                if (StringUtils.isEmpty(projectName)) {
                        if (!StringUtils.isEmpty(userName)) {
-                               projectName = ModelUtils.getPersonalPath(userName);
+                               projectName = ModelUtils.getPersonalProject(userName);
                        }
                }
                String repositoryName = WicketUtils.getRepositoryName(params);
index 62d07a7f81815c63f0e1a91d8c37d335f51cff13..53ed198f30c6ea1386d9683fea704ab2ff0ab757 100644 (file)
@@ -89,17 +89,16 @@ public abstract class RootSubPage extends RootPage {
                        RepositoryModel repositoryModel = app().repositories().getRepositoryModel(repo);\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
+                               if (user != null && user.isOwner(repositoryModel)) {\r
                                        // exclude Owner or personal repositories\r
                                        continue;\r
                                }\r
                                if (includeWildcards) {\r
-                                       if (lastProject == null || !lastProject.equalsIgnoreCase(repositoryModel.projectPath)) {\r
-                                               lastProject = repositoryModel.projectPath.toLowerCase();\r
-                                               if (!StringUtils.isEmpty(repositoryModel.projectPath)) {\r
+                                       if (lastProject == null || !lastProject.equalsIgnoreCase(repositoryModel.getProject())) {\r
+                                               lastProject = repositoryModel.getProject().toLowerCase();\r
+                                               if (!StringUtils.isEmpty(repositoryModel.getProject())) {\r
                                                        // regex for all repositories within a project\r
-                                                       repos.add(repositoryModel.projectPath + "/.*");\r
+                                                       repos.add(repositoryModel.getProjectPath() + "/.*");\r
                                                }\r
                                        }\r
                                }\r
index 090c09526884f0bc07f3bfa9d15ff9d9240c4368..a3544c707cd845e6d3d470c5176dd1bb6e05321e 100644 (file)
@@ -18,7 +18,6 @@ package com.gitblit.wicket.pages;
 import java.text.MessageFormat;\r
 import java.text.ParseException;\r
 import java.text.SimpleDateFormat;\r
-import java.util.ArrayList;\r
 import java.util.Date;\r
 import java.util.List;\r
 \r
@@ -36,6 +35,7 @@ import org.eclipse.jgit.revwalk.RevCommit;
 \r
 import com.gitblit.Keys;\r
 import com.gitblit.models.Metric;\r
+import com.gitblit.models.Owner;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.UserModel;\r
 import com.gitblit.utils.JGitUtils;\r
@@ -88,23 +88,18 @@ public class SummaryPage extends RepositoryPage {
                add(new Label("repositoryDescription", getRepositoryModel().description));\r
 \r
                // owner links\r
-               final List<String> owners = new ArrayList<String>(getRepositoryModel().owners);\r
-               ListDataProvider<String> ownersDp = new ListDataProvider<String>(owners);\r
-               DataView<String> ownersView = new DataView<String>("repositoryOwners", ownersDp) {\r
+               final List<Owner> owners = app().users().getOwners(getRepositoryModel());\r
+               ListDataProvider<Owner> ownersDp = new ListDataProvider<>(owners);\r
+               DataView<Owner> ownersView = new DataView<Owner>("repositoryOwners", ownersDp) {\r
                        private static final long serialVersionUID = 1L;\r
                        int counter = 0;\r
                        @Override\r
-                       public void populateItem(final Item<String> item) {\r
-                               String ownername = item.getModelObject();\r
-                               UserModel ownerModel = app().users().getUserModel(ownername);\r
-                               if (ownerModel != null) {\r
+                       public void populateItem(final Item<Owner> item) {\r
+                               Owner owner = item.getModelObject();\r
+                               if (owner instanceof UserModel) {\r
+                                       UserModel ownerModel = (UserModel) owner;\r
                                        item.add(new LinkPanel("owner", null, ownerModel.getDisplayName(), UserPage.class,\r
                                                        WicketUtils.newUsernameParameter(ownerModel.username)).setRenderBodyOnly(true));\r
-                               } else {\r
-                                       Label owner = new Label("owner", ownername);\r
-                                       WicketUtils.setCssStyle(owner, "text-decoration: line-through;");\r
-                                       WicketUtils.setHtmlTooltip(owner,  MessageFormat.format(getString("gb.failedToFindAccount"), ownername));\r
-                                       item.add(owner);\r
                                }\r
                                counter++;\r
                                item.add(new Label("comma", ",").setVisible(counter < owners.size()));\r
index 8630d2018a3594d9253990a4b1eb8d1fc5209584..a30faff14ef8783823a0d0527756bab54e0c46a3 100644 (file)
@@ -15,6 +15,7 @@
  */\r
 package com.gitblit.wicket.panels;\r
 \r
+import java.util.List;\r
 import java.util.Map;\r
 \r
 import org.apache.wicket.Component;\r
@@ -27,6 +28,7 @@ import org.apache.wicket.markup.html.panel.Fragment;
 \r
 import com.gitblit.Constants.AccessRestrictionType;\r
 import com.gitblit.Keys;\r
+import com.gitblit.models.Owner;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.UserModel;\r
 import com.gitblit.servlet.SyndicationServlet;\r
@@ -64,7 +66,7 @@ public class ProjectRepositoryPanel extends BasePanel {
                swatch.setVisible(showSwatch);\r
 \r
                PageParameters pp = WicketUtils.newRepositoryParameter(entry.name);\r
-               add(new LinkPanel("repositoryName", "list", StringUtils.getRelativePath(entry.projectPath,\r
+               add(new LinkPanel("repositoryName", "list", StringUtils.getRelativePath(entry.getProject(),\r
                                StringUtils.stripDotGit(entry.name)), SummaryPage.class, pp));\r
                add(new Label("repositoryDescription", entry.description).setVisible(!StringUtils\r
                                .isEmpty(entry.description)));\r
@@ -102,23 +104,17 @@ public class ProjectRepositoryPanel extends BasePanel {
                        add(WicketUtils.newClearPixel("federatedIcon").setVisible(false));\r
                }\r
 \r
-               if (ArrayUtils.isEmpty(entry.owners)) {\r
+               List<Owner> owners = app().users().getOwners(entry);\r
+               if (ArrayUtils.isEmpty(owners)) {\r
                        add(new Label("repositoryOwner").setVisible(false));\r
                } else {\r
-                       String owner = "";\r
-                       for (String username : entry.owners) {\r
-                               UserModel ownerModel = app().users().getUserModel(username);\r
-\r
-                               if (ownerModel != null) {\r
-                                       owner = ownerModel.getDisplayName();\r
-                               }\r
-                       }\r
-                       if (entry.owners.size() > 1) {\r
+                       String owner = owners.get(0).getDisplayName();\r
+                       if (owners.size() > 1) {\r
                                owner += ", ...";\r
                        }\r
                        Label ownerLabel = (new Label("repositoryOwner", owner + " (" +\r
                                        localizer.getString("gb.owner", parent) + ")"));\r
-                       WicketUtils.setHtmlTooltip(ownerLabel, ArrayUtils.toString(entry.owners));\r
+                       WicketUtils.setHtmlTooltip(ownerLabel, ArrayUtils.toString(owners));\r
                        add(ownerLabel);\r
                }\r
 \r
index 8573e1a6a5d9f5bea5fca1810fca03058730724a..49ec0489d56ebcfd7b32363e4d833dad6561d405 100644 (file)
@@ -42,6 +42,7 @@ import org.apache.wicket.model.Model;
 \r
 import com.gitblit.Constants.AccessRestrictionType;\r
 import com.gitblit.Keys;\r
+import com.gitblit.models.Owner;\r
 import com.gitblit.models.ProjectModel;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.UserModel;\r
@@ -275,22 +276,17 @@ public class RepositoriesPanel extends BasePanel {
                                        row.add(WicketUtils.newBlankImage("accessRestrictionIcon"));\r
                                }\r
 \r
+                               List<Owner> owners = app().users().getOwners(entry);\r
+                               // display first owner\r
                                String owner = "";\r
-                               if (!ArrayUtils.isEmpty(entry.owners)) {\r
-                                       // display first owner\r
-                                       for (String username : entry.owners) {\r
-                                               UserModel ownerModel = app().users().getUserModel(username);\r
-                                               if (ownerModel != null) {\r
-                                                       owner = ownerModel.getDisplayName();\r
-                                                       break;\r
-                                               }\r
-                                       }\r
-                                       if (entry.owners.size() > 1) {\r
+                               if (!owners.isEmpty()) {\r
+                                       owner = owners.get(0).getDisplayName();\r
+                                       if (owners.size() > 1) {\r
                                                owner += ", ...";\r
                                        }\r
                                }\r
                                Label ownerLabel = new Label("repositoryOwner", owner);\r
-                               WicketUtils.setHtmlTooltip(ownerLabel, ArrayUtils.toString(entry.owners));\r
+                               WicketUtils.setHtmlTooltip(ownerLabel, ArrayUtils.toString(owners));\r
                                row.add(ownerLabel);\r
 \r
                                String lastChange;\r
@@ -336,7 +332,7 @@ public class RepositoriesPanel extends BasePanel {
                String title;\r
 \r
                GroupRepositoryModel(String name, int count) {\r
-                       super(name, "", "", new Date(0));\r
+                       super(name, "", new Date(0));\r
                        this.count = count;\r
                }\r
 \r
@@ -412,18 +408,6 @@ public class RepositoriesPanel extends BasePanel {
                                                return o2.name.compareTo(o1.name);\r
                                        }\r
                                });\r
-                       } else if (prop.equals(SortBy.owner.name())) {\r
-                               Collections.sort(list, new Comparator<RepositoryModel>() {\r
-                                       @Override\r
-                                       public int compare(RepositoryModel o1, RepositoryModel o2) {\r
-                                               String own1 = ArrayUtils.toString(o1.owners);\r
-                                               String own2 = ArrayUtils.toString(o2.owners);\r
-                                               if (asc) {\r
-                                                       return own1.compareTo(own2);\r
-                                               }\r
-                                               return own2.compareTo(own1);\r
-                                       }\r
-                               });\r
                        } else if (prop.equals(SortBy.description.name())) {\r
                                Collections.sort(list, new Comparator<RepositoryModel>() {\r
                                        @Override\r
index f381a45ec7c54de9573328bbf99baaa7a8c94613..2b2a3adf28f551e34e818e4efabaa8631600e2d1 100644 (file)
-/*\r
- * Copyright 2014 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.gitblit.wicket.panels;\r
-\r
-import java.text.MessageFormat;\r
-import java.util.ArrayList;\r
-import java.util.Set;\r
-import java.util.TreeSet;\r
-\r
-import org.apache.wicket.markup.html.form.DropDownChoice;\r
-import org.apache.wicket.markup.html.form.TextField;\r
-import org.apache.wicket.model.IModel;\r
-import org.apache.wicket.model.Model;\r
-\r
-import com.gitblit.models.ProjectModel;\r
-import com.gitblit.models.RepositoryModel;\r
-import com.gitblit.models.UserModel;\r
-import com.gitblit.utils.StringUtils;\r
-import com.gitblit.wicket.GitBlitWebSession;\r
-\r
-/**\r
- * A panel for naming a repository, specifying it's project, and entering a description.\r
- *\r
- * @author James Moger\r
- *\r
- */\r
-public class RepositoryNamePanel extends BasePanel {\r
-\r
-       private static final long serialVersionUID = 1L;\r
-\r
-       private String fullName;\r
-\r
-       private final IModel<String> projectPath;\r
-\r
-       private DropDownChoice<String> pathChoice;\r
-\r
-       private final IModel<String> repoName;\r
-\r
-       private TextField<String> nameField;\r
-\r
-       public RepositoryNamePanel(String wicketId, RepositoryModel repository) {\r
-               super(wicketId);\r
-\r
-               GitBlitWebSession session = GitBlitWebSession.get();\r
-               UserModel user = session.getUser();\r
-\r
-               // build project set for repository destination\r
-               String defaultPath = null;\r
-               String defaultName = null;\r
-               Set<String> pathNames = new TreeSet<String>();\r
-\r
-               // add the registered/known projects\r
-               for (ProjectModel project : app().projects().getProjectModels(user, false)) {\r
-                       // TODO issue-351: user.canAdmin(project)\r
-                       if (user.canAdmin()) {\r
-                               if (project.isRoot) {\r
-                                       pathNames.add("/");\r
-                               } else {\r
-                                       pathNames.add(project.name + "/");\r
-                               }\r
-                       }\r
-               }\r
-\r
-               // add the user's personal project namespace\r
-               if (user.canAdmin() || user.canCreate()) {\r
-                       pathNames.add(user.getPersonalPath() + "/");\r
-               }\r
-\r
-               if (!StringUtils.isEmpty(repository.name)) {\r
-                       // editing a repository name\r
-                       // set the defaultProject to the current repository project\r
-                       if (StringUtils.isEmpty(repository.projectPath)) {\r
-                               defaultPath = "/";\r
-                               defaultName = repository.name;\r
-                       } else {\r
-                               defaultPath = repository.projectPath + "/";\r
-                               defaultName = repository.name.substring(defaultPath.length());\r
-                       }\r
-                       pathNames.add(defaultPath);\r
-               }\r
-\r
-               // if default project is not already set, set preference based on the user permissions\r
-               if (defaultPath == null) {\r
-                       if (user.canAdmin()) {\r
-                               defaultPath = "/";\r
-                       } else if (user.canCreate()) {\r
-                               defaultPath = user.getPersonalPath() + "/";\r
-                       }\r
-               }\r
-\r
-               projectPath = Model.of(defaultPath);\r
-               pathChoice = new DropDownChoice<String>("projectPath", projectPath, new ArrayList<String>(pathNames));\r
-               repoName = Model.of(defaultName);\r
-               nameField = new TextField<String>("name", repoName);\r
-\r
-               // only enable project selection if we actually have multiple choices\r
-               add(pathChoice.setEnabled(pathNames.size() > 1));\r
-               add(nameField);\r
-               add(new TextField<String>("description"));\r
-       }\r
-\r
-       public void setEditable(boolean editable) {\r
-               // only enable project selection if we actually have multiple choices\r
-               pathChoice.setEnabled(pathChoice.getChoices().size() > 1 && editable);\r
-               nameField.setEnabled(editable);\r
-       }\r
-\r
-       public boolean updateModel(RepositoryModel repositoryModel) {\r
-               // confirm a project path was selected\r
-               if (StringUtils.isEmpty(projectPath.getObject())) {\r
-                       error(getString("gb.pleaseSelectProject"));\r
-                       return false;\r
-               }\r
-\r
-               // confirm a repository name was entered\r
-               if (StringUtils.isEmpty(repoName.getObject())) {\r
-                       error(getString("gb.pleaseSetRepositoryName"));\r
-                       return false;\r
-               }\r
-\r
-               String project = projectPath.getObject();\r
-               String name = repoName.getObject();\r
-\r
-               fullName = (project + name).trim();\r
-               fullName = fullName.replace('\\', '/');\r
-               fullName = fullName.replace("//", "/");\r
-               if (fullName.charAt(0) == '/') {\r
-                       fullName = fullName.substring(1);\r
-               }\r
-               if (fullName.endsWith("/")) {\r
-                       fullName = fullName.substring(0, fullName.length() - 1);\r
-               }\r
-\r
-               if (fullName.contains("../")) {\r
-                       error(getString("gb.illegalRelativeSlash"));\r
-                       return false;\r
-               }\r
-               if (fullName.contains("/../")) {\r
-                       error(getString("gb.illegalRelativeSlash"));\r
-                       return false;\r
-               }\r
-\r
-               // confirm valid characters in repository name\r
-               Character c = StringUtils.findInvalidCharacter(fullName);\r
-               if (c != null) {\r
-                       error(MessageFormat.format(getString("gb.illegalCharacterRepositoryName"), c));\r
-                       return false;\r
-               }\r
-\r
-               repositoryModel.name = fullName;\r
-\r
-               return true;\r
-       }\r
-\r
-       @Override\r
-       protected boolean getStatelessHint() {\r
-               return false;\r
-       }\r
+/*
+ * Copyright 2014 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gitblit.wicket.panels;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.wicket.markup.html.form.DropDownChoice;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+
+import com.gitblit.models.ProjectModel;
+import com.gitblit.models.RepositoryModel;
+import com.gitblit.models.UserModel;
+import com.gitblit.utils.StringUtils;
+import com.gitblit.wicket.GitBlitWebSession;
+
+/**
+ * A panel for naming a repository, specifying it's project, and entering a description.
+ *
+ * @author James Moger
+ *
+ */
+public class RepositoryNamePanel extends BasePanel {
+
+       private static final long serialVersionUID = 1L;
+
+       private String fullName;
+
+       private final IModel<String> projectPath;
+
+       private DropDownChoice<String> pathChoice;
+
+       private final IModel<String> repoName;
+
+       private TextField<String> nameField;
+
+       public RepositoryNamePanel(String wicketId, RepositoryModel repository) {
+               super(wicketId);
+
+               GitBlitWebSession session = GitBlitWebSession.get();
+               UserModel user = session.getUser();
+
+               // build project set for repository destination
+               String defaultPath = null;
+               String defaultName = null;
+               Set<String> pathNames = new TreeSet<String>();
+
+//             // add all specified project paths
+//             if (user.ownerOf != null) {
+//                     for (String path : user.ownerOf) {
+//                             if (path.charAt(path.length() - 1) == '/') {
+//                                     projectNames.add(path);
+//                             }
+//                     }
+//             }
+//
+               // add the registered/known projects
+               for (ProjectModel project : app().projects().getProjectModels(user, false)) {
+                       // TODO issue-351: user.canAdmin(project)
+                       if (user.canAdmin()) {
+                               if (project.isRoot) {
+                                       pathNames.add("/");
+                               } else {
+                                       pathNames.add(project.name + "/");
+                               }
+                       }
+               }
+
+               // add the user's personal project namespace
+               if (user.canAdmin() || user.canCreate()) {
+                       pathNames.add(user.getPersonalPath());
+               }
+
+               if (!StringUtils.isEmpty(repository.name)) {
+                       // editing a repository name
+                       // set the defaultProject to the current repository project
+                       defaultPath = repository.getProjectPath();
+                       defaultName = repository.name.substring(defaultPath.length());
+                       pathNames.add(defaultPath);
+               }
+
+               // if default project is not already set, set preference based on the user permissions
+               if (defaultPath == null) {
+                       if (user.canAdmin()) {
+                               defaultPath = "/";
+                       } else if (user.canCreate()) {
+                               defaultPath = user.getPersonalPath();
+                       }
+               }
+
+               projectPath = Model.of(defaultPath);
+               pathChoice = new DropDownChoice<String>("projectPath", projectPath, new ArrayList<String>(pathNames));
+               repoName = Model.of(defaultName);
+               nameField = new TextField<String>("name", repoName);
+
+               // only enable project selection if we actually have multiple choices
+               add(pathChoice.setEnabled(pathNames.size() > 1));
+               add(nameField);
+               add(new TextField<String>("description"));
+       }
+
+       public void setEditable(boolean editable) {
+               // only enable project selection if we actually have multiple choices
+               pathChoice.setEnabled(pathChoice.getChoices().size() > 1 && editable);
+               nameField.setEnabled(editable);
+       }
+
+       public boolean updateModel(RepositoryModel repositoryModel) {
+               // confirm a project path was selected
+               if (StringUtils.isEmpty(projectPath.getObject())) {
+                       error(getString("gb.pleaseSelectProject"));
+                       return false;
+               }
+
+               // confirm a repository name was entered
+               if (StringUtils.isEmpty(repoName.getObject())) {
+                       error(getString("gb.pleaseSetRepositoryName"));
+                       return false;
+               }
+
+               String project = projectPath.getObject();
+               String name = repoName.getObject();
+
+               fullName = (project + name).trim();
+               fullName = fullName.replace('\\', '/');
+               fullName = fullName.replace("//", "/");
+               if (fullName.charAt(0) == '/') {
+                       fullName = fullName.substring(1);
+               }
+               if (fullName.endsWith("/")) {
+                       fullName = fullName.substring(0, fullName.length() - 1);
+               }
+
+               if (fullName.contains("../")) {
+                       error(getString("gb.illegalRelativeSlash"));
+                       return false;
+               }
+               if (fullName.contains("/../")) {
+                       error(getString("gb.illegalRelativeSlash"));
+                       return false;
+               }
+
+               // confirm valid characters in repository name
+               Character c = StringUtils.findInvalidCharacter(fullName);
+               if (c != null) {
+                       error(MessageFormat.format(getString("gb.illegalCharacterRepositoryName"), c));
+                       return false;
+               }
+
+               repositoryModel.name = fullName;
+
+               return true;
+       }
+
+       @Override
+       protected boolean getStatelessHint() {
+               return false;
+       }
 }
\ No newline at end of file
index 4361410c7e305ef9a208e461473422f53c7f0998..49fa8632ad9712d10d174018305925573a50f46e 100644 (file)
@@ -5,6 +5,7 @@
        emailMeOnMyTicketChanges = true
        role = "#admin"
        role = "#notfederated"
+       owns = ~admin/helloworld.git
 [team "admins"]
        role = "#none"
        accountType = LOCAL
index cc404abf84458fc19716120791e6535f7c5b96c5..42dd8a8efc234b74d14feed43e45ecb1a778f948 100644 (file)
@@ -38,7 +38,7 @@ import com.gitblit.tickets.ITicketService;
  */
 public class BranchTicketServiceTest extends TicketServiceTest {
 
-       final RepositoryModel repo = new RepositoryModel("tickets/branch.git", null, null, null);
+       final RepositoryModel repo = new RepositoryModel("tickets/branch.git", null, null);
 
        @Override
        protected RepositoryModel getRepository() {
index 144fe3da8682784599f9a2127e344b6d35a4089c..abf24f2de003ccfa24a6f9596fb115e6fefdfc7d 100644 (file)
@@ -68,7 +68,6 @@ public class FederationTests extends GitblitUnitTest {
                        model.accessRestriction = AccessRestrictionType.VIEW;\r
                        model.description = "cloneable repository " + i;\r
                        model.lastChange = new Date();\r
-                       model.addOwner("adminuser");\r
                        model.name = "repo" + i + ".git";\r
                        model.size = "5 MB";\r
                        model.hasCommits = true;\r
index 6ede042a0475e9563332d2cb28165e0318db184d..126b9c77510c3b7f899b372c72c2b38d040ee635 100644 (file)
@@ -38,7 +38,7 @@ import com.gitblit.tickets.ITicketService;
  */
 public class FileTicketServiceTest extends TicketServiceTest {
 
-       final RepositoryModel repo = new RepositoryModel("tickets/file.git", null, null, null);
+       final RepositoryModel repo = new RepositoryModel("tickets/file.git", null, null);
 
        @Override
        protected RepositoryModel getRepository() {
index 705684a3180ed1302f53d4ae5a6b94d4437b8370..4ec842241f5209bfb1fdd46b906ef4f5833b0b51 100644 (file)
@@ -53,7 +53,6 @@ import com.gitblit.Keys;
 import com.gitblit.models.RefLogEntry;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.UserModel;\r
-import com.gitblit.utils.ArrayUtils;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.RefLogUtils;\r
 \r
@@ -879,7 +878,8 @@ public class GitServletTest extends GitblitUnitTest {
 \r
                        // confirm default personal repository permissions\r
                        RepositoryModel model = repositories().getRepositoryModel(MessageFormat.format("~{0}/ticgit.git", user.username));\r
-                       assertEquals("Unexpected owner", user.username, ArrayUtils.toString(model.owners));\r
+                       user = gitblit().getUserModel(user.username);\r
+                       assertTrue("Unexpected owner", user.isOwner(model));\r
                        assertEquals("Unexpected authorization control", AuthorizationControl.NAMED, model.authorizationControl);\r
                        assertEquals("Unexpected access restriction", AccessRestrictionType.VIEW, model.accessRestriction);\r
 \r
@@ -903,7 +903,8 @@ public class GitServletTest extends GitblitUnitTest {
 \r
                        // confirm default project repository permissions\r
                        RepositoryModel model = repositories().getRepositoryModel("project/ticgit.git");\r
-                       assertEquals("Unexpected owner", user.username, ArrayUtils.toString(model.owners));\r
+                       user = gitblit().getUserModel(user.username);\r
+                       assertTrue("Unexpected owner", user.isOwner(model));\r
                        assertEquals("Unexpected authorization control", AuthorizationControl.fromName(settings().getString(Keys.git.defaultAuthorizationControl, "NAMED")), model.authorizationControl);\r
                        assertEquals("Unexpected access restriction", AccessRestrictionType.fromName(settings().getString(Keys.git.defaultAccessRestriction, "NONE")), model.accessRestriction);\r
 \r
index ff40972f4fd40cec6f338c5d78c81e2bffc20ecb..c73498e1e4c59f51a4bfdce38dc85f10a8b98e41 100644 (file)
@@ -147,7 +147,7 @@ public class GroovyScriptTest extends GitblitUnitTest {
                commands.add(new ReceiveCommand(ObjectId.zeroId(), ObjectId\r
                                .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));\r
 \r
-               RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());\r
+               RepositoryModel repository = new RepositoryModel("ex@mple.git", "", new Date());\r
 \r
                test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);\r
        }\r
@@ -161,7 +161,7 @@ public class GroovyScriptTest extends GitblitUnitTest {
                commands.add(new ReceiveCommand(ObjectId.zeroId(), ObjectId\r
                                .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/tags/v1.0"));\r
 \r
-               RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());\r
+               RepositoryModel repository = new RepositoryModel("ex@mple.git", "", new Date());\r
 \r
                test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);\r
                assertEquals(0, logger.messages.size());\r
@@ -177,7 +177,7 @@ public class GroovyScriptTest extends GitblitUnitTest {
                                .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId\r
                                .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));\r
 \r
-               RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());\r
+               RepositoryModel repository = new RepositoryModel("ex@mple.git", "", new Date());\r
 \r
                test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);\r
                assertEquals(0, logger.messages.size());\r
@@ -194,7 +194,7 @@ public class GroovyScriptTest extends GitblitUnitTest {
                                "refs/heads/master");\r
                commands.add(command);\r
 \r
-               RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());\r
+               RepositoryModel repository = new RepositoryModel("ex@mple.git", "", new Date());\r
 \r
                test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);\r
                assertEquals(ReceiveCommand.Result.REJECTED_NODELETE, command.getResult());\r
@@ -211,7 +211,7 @@ public class GroovyScriptTest extends GitblitUnitTest {
                                .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), ObjectId.zeroId(),\r
                                "refs/heads/other"));\r
 \r
-               RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());\r
+               RepositoryModel repository = new RepositoryModel("ex@mple.git", "", new Date());\r
 \r
                test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);\r
                assertEquals(0, logger.messages.size());\r
@@ -228,7 +228,7 @@ public class GroovyScriptTest extends GitblitUnitTest {
                                "refs/tags/v1.0");\r
                commands.add(command);\r
 \r
-               RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());\r
+               RepositoryModel repository = new RepositoryModel("ex@mple.git", "", new Date());\r
 \r
                test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);\r
                assertEquals(ReceiveCommand.Result.REJECTED_NODELETE, command.getResult());\r
@@ -245,7 +245,7 @@ public class GroovyScriptTest extends GitblitUnitTest {
                                .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId\r
                                .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));\r
 \r
-               RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());\r
+               RepositoryModel repository = new RepositoryModel("ex@mple.git", "", new Date());\r
 \r
                try {\r
                        test("blockpush.groovy", gitblit, logger, clientLogger, commands, repository);\r
@@ -265,7 +265,7 @@ public class GroovyScriptTest extends GitblitUnitTest {
                                .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId\r
                                .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));\r
 \r
-               RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());\r
+               RepositoryModel repository = new RepositoryModel("ex@mple.git", "", new Date());\r
 \r
                File groovyDir = repositories().getHooksFolder();\r
                File tempScript = File.createTempFile("testClientLogging", "groovy", groovyDir);\r
index e34e0aa47bd1f54c8f9fd284658ae1f0042202b5..dfccc1463cfd56776141cce39e3771e5ff6e0027 100644 (file)
@@ -4,6 +4,7 @@ import org.junit.After;
 import org.junit.Test;
 
 import com.gitblit.Constants;
+import com.gitblit.models.UserModel;
 import com.gitblit.utils.ModelUtils;
 
 public class ModelUtilsTest extends GitblitUnitTest {
@@ -48,18 +49,33 @@ public class ModelUtilsTest extends GitblitUnitTest {
        }
 
 
+       @Test
+       public void testGetPersonalProject()
+       {
+               String username = "rob";
+               assertEquals(Constants.DEFAULT_USER_REPOSITORY_PREFIX+username.toLowerCase(), ModelUtils.getPersonalProject(username));
+
+               username = "James";
+               assertEquals(Constants.DEFAULT_USER_REPOSITORY_PREFIX+username.toLowerCase(), ModelUtils.getPersonalProject(username));
+
+               ModelUtils.setUserRepoPrefix("usr/");
+               username = "noMan";
+               assertEquals("usr/"+username.toLowerCase(), ModelUtils.getPersonalProject(username));
+       }
+
+
        @Test
        public void testGetPersonalPath()
        {
                String username = "rob";
-               assertEquals(Constants.DEFAULT_USER_REPOSITORY_PREFIX+username.toLowerCase(), ModelUtils.getPersonalPath(username));
+               assertEquals(Constants.DEFAULT_USER_REPOSITORY_PREFIX+username.toLowerCase() + "/", ModelUtils.getPersonalPath(username));
 
                username = "James";
-               assertEquals(Constants.DEFAULT_USER_REPOSITORY_PREFIX+username.toLowerCase(), ModelUtils.getPersonalPath(username));
+               assertEquals(Constants.DEFAULT_USER_REPOSITORY_PREFIX+username.toLowerCase() + "/", ModelUtils.getPersonalPath(username));
 
                ModelUtils.setUserRepoPrefix("usr/");
                username = "noMan";
-               assertEquals("usr/"+username.toLowerCase(), ModelUtils.getPersonalPath(username));
+               assertEquals("usr/"+username.toLowerCase() + "/", ModelUtils.getPersonalPath(username));
        }
 
 
@@ -124,4 +140,19 @@ public class ModelUtilsTest extends GitblitUnitTest {
                assertEquals("fee", ModelUtils.getUserNameFromRepoPath(reponame));
        }
 
+       @Test
+       public void testUserOwnership() {
+               ModelUtils.setUserRepoPrefix(Constants.DEFAULT_USER_REPOSITORY_PREFIX);
+               UserModel user = new UserModel("james");
+               user.own("test.git");
+               user.own("newyork/.*");
+
+               assertFalse(user.isOwner("test"));
+               assertTrue(user.isOwner("test.git"));
+               assertFalse(user.isOwner("newyork"));
+               assertTrue(user.isOwner("newyork/"));
+               assertTrue(user.isOwner("newyork/abc"));
+               assertTrue(user.isOwner("~james/"));
+               assertTrue(user.isOwner("~james/abc/123"));
+       }
 }
index 46695e951ce391bd9ed986f12f52259c59bd2024..9e04c0b57a96185e66b0841685c52908a0346f0b 100644 (file)
@@ -43,7 +43,7 @@ public class PermissionsTest extends GitblitUnitTest {
                user.canAdmin = true;
 
                for (AccessRestrictionType ar : AccessRestrictionType.values()) {
-                       RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+                       RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                        repository.authorizationControl = AuthorizationControl.NAMED;
                        repository.accessRestriction = ar;
 
@@ -69,7 +69,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testAnonymous_NONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -97,7 +97,7 @@ public class PermissionsTest extends GitblitUnitTest {
 
        @Test
        public void testAnonymous_PUSH() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -121,7 +121,7 @@ public class PermissionsTest extends GitblitUnitTest {
 
        @Test
        public void testAnonymous_CLONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -145,7 +145,7 @@ public class PermissionsTest extends GitblitUnitTest {
 
        @Test
        public void testAnonymous_VIEW() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -172,7 +172,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testAuthenticated_NONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.AUTHENTICATED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -203,7 +203,7 @@ public class PermissionsTest extends GitblitUnitTest {
 
        @Test
        public void testAuthenticated_PUSH() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.AUTHENTICATED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -230,7 +230,7 @@ public class PermissionsTest extends GitblitUnitTest {
 
        @Test
        public void testAuthenticated_CLONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.AUTHENTICATED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -257,7 +257,7 @@ public class PermissionsTest extends GitblitUnitTest {
 
        @Test
        public void testAuthenticated_VIEW() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.AUTHENTICATED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -287,7 +287,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_NONE_NONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -320,7 +320,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_PUSH_NONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -350,7 +350,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_CLONE_NONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -380,7 +380,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_VIEW_NONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -412,7 +412,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_NONE_VIEW() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -443,7 +443,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_PUSH_VIEW() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -474,7 +474,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_CLONE_VIEW() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -505,7 +505,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_VIEW_VIEW() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -537,7 +537,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_NONE_CLONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -568,7 +568,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_PUSH_CLONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -599,7 +599,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_CLONE_CLONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -630,7 +630,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_VIEW_CLONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -662,7 +662,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_NONE_PUSH() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -693,7 +693,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_PUSH_PUSH() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -724,7 +724,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_CLONE_PUSH() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -755,7 +755,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_VIEW_PUSH() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -787,7 +787,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_NONE_CREATE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -818,7 +818,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_PUSH_CREATE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -849,7 +849,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_CLONE_CREATE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -880,7 +880,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_VIEW_CREATE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -912,7 +912,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_NONE_DELETE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -943,7 +943,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_PUSH_DELETE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -974,7 +974,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_CLONE_DELETE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -1005,7 +1005,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_VIEW_DELETE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -1037,7 +1037,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_NONE_REWIND() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -1068,7 +1068,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_PUSH_REWIND() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -1099,7 +1099,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_CLONE_REWIND() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -1130,7 +1130,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testNamed_VIEW_REWIND() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -1161,7 +1161,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_NONE_NONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -1184,7 +1184,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_PUSH_NONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -1207,7 +1207,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_CLONE_NONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -1229,7 +1229,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_VIEW_NONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -1252,7 +1252,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_NONE_PUSH() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -1275,7 +1275,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_PUSH_PUSH() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -1298,7 +1298,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_CLONE_PUSH() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -1321,7 +1321,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_VIEW_PUSH() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -1345,7 +1345,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_NONE_CREATE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -1368,7 +1368,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_PUSH_CREATE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -1391,7 +1391,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_CLONE_CREATE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -1414,7 +1414,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_VIEW_CREATE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -1438,7 +1438,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_NONE_DELETE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -1461,7 +1461,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_PUSH_DELETE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -1484,7 +1484,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_CLONE_DELETE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -1507,7 +1507,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_VIEW_DELETE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -1531,7 +1531,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_NONE_REWIND() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -1554,7 +1554,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_PUSH_REWIND() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -1577,7 +1577,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_CLONE_REWIND() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -1600,7 +1600,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_VIEW_REWIND() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -1624,7 +1624,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_NONE_CLONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -1647,7 +1647,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_PUSH_CLONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -1670,7 +1670,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_CLONE_CLONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -1693,7 +1693,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_VIEW_CLONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -1717,7 +1717,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_NONE_VIEW() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -1740,7 +1740,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_PUSH_VIEW() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -1763,7 +1763,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_CLONE_VIEW() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -1786,7 +1786,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeam_VIEW_VIEW() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -1809,7 +1809,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_NONE_NONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -1833,7 +1833,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_PUSH_NONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -1857,7 +1857,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_CLONE_NONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -1881,7 +1881,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_VIEW_NONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -1906,7 +1906,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_NONE_PUSH() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -1931,7 +1931,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_PUSH_PUSH() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -1956,7 +1956,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_CLONE_PUSH() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -1981,7 +1981,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_VIEW_PUSH() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -2007,7 +2007,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_NONE_CREATE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -2032,7 +2032,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_PUSH_CREATE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -2057,7 +2057,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_CLONE_CREATE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -2082,7 +2082,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_VIEW_CREATE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -2108,7 +2108,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_NONE_DELETE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -2133,7 +2133,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_PUSH_DELETE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -2158,7 +2158,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_CLONE_DELETE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -2183,7 +2183,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_VIEW_DELETE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -2209,7 +2209,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_NONE_REWIND() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -2234,7 +2234,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_PUSH_REWIND() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -2259,7 +2259,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_CLONE_REWIND() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -2284,7 +2284,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_VIEW_REWIND() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -2310,7 +2310,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_NONE_CLONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -2335,7 +2335,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_PUSH_CLONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -2360,7 +2360,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_CLONE_CLONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -2385,7 +2385,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_VIEW_CLONE() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -2411,7 +2411,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_NONE_VIEW() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.NONE;
 
@@ -2436,7 +2436,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_PUSH_VIEW() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.PUSH;
 
@@ -2461,7 +2461,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_CLONE_VIEW() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.CLONE;
 
@@ -2486,7 +2486,7 @@ public class PermissionsTest extends GitblitUnitTest {
         */
        @Test
        public void testTeamMember_VIEW_VIEW() throws Exception {
-               RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -2508,12 +2508,12 @@ public class PermissionsTest extends GitblitUnitTest {
 
        @Test
        public void testOwner() throws Exception {
-               RepositoryModel repository = new RepositoryModel("~jj/myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("~jj/myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
                UserModel user = new UserModel("test");
-               repository.addOwner(user.username);
+               user.own(repository);
 
                assertFalse("user SHOULD NOT HAVE a repository permission!", user.hasRepositoryPermission(repository.name));
                assertTrue("owner CAN NOT view!", user.canView(repository));
@@ -2528,7 +2528,7 @@ public class PermissionsTest extends GitblitUnitTest {
 
                assertTrue("owner CAN NOT fork!", user.canFork(repository));
 
-               assertFalse("owner CAN NOT delete!", user.canDelete(repository));
+               assertFalse("owner CAN delete someone elses personal repo!", user.canDelete(repository));
                assertTrue("owner CAN NOT edit!", user.canEdit(repository));
 
                // test personal repo owner
@@ -2548,19 +2548,19 @@ public class PermissionsTest extends GitblitUnitTest {
 
                assertTrue("jj CAN NOT delete!", jj.canDelete(repository));
                assertTrue("jj CAN NOT edit!", jj.canEdit(repository));
-               assertTrue(repository.isOwner(jj.username));
+               assertTrue(jj.isOwner(repository));
        }
 
        @Test
        public void testMultipleOwners() throws Exception {
-               RepositoryModel repository = new RepositoryModel("~jj/myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("~jj/myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
                UserModel user = new UserModel("test");
-               repository.addOwner(user.username);
+               user.own(repository);
                UserModel user2 = new UserModel("test2");
-               repository.addOwner(user2.username);
+               user2.own(repository);
 
                // first owner
                assertFalse("user SHOULD NOT HAVE a repository permission!", user.hasRepositoryPermission(repository.name));
@@ -2596,8 +2596,8 @@ public class PermissionsTest extends GitblitUnitTest {
                assertFalse("owner CAN NOT delete!", user2.canDelete(repository));
                assertTrue("owner CAN NOT edit!", user2.canEdit(repository));
 
-               assertTrue(repository.isOwner(user.username));
-               assertTrue(repository.isOwner(user2.username));
+               assertTrue(user.isOwner(repository));
+               assertTrue(user2.isOwner(repository));
 
                // test personal repo owner
                UserModel jj = new UserModel("jj");
@@ -2616,17 +2616,17 @@ public class PermissionsTest extends GitblitUnitTest {
 
                assertTrue("jj CAN NOT delete!", jj.canDelete(repository));
                assertTrue("jj CAN NOT edit!", jj.canEdit(repository));
-               assertTrue(repository.isOwner(jj.username));
+               assertTrue(jj.isOwner(repository));
        }
 
        @Test
        public void testOwnerPersonalRepository() throws Exception {
-               RepositoryModel repository = new RepositoryModel("~test/myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("~test/myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
                UserModel user = new UserModel("test");
-               repository.addOwner(user.username);
+               user.own(repository);
 
                assertFalse("user SHOULD NOT HAVE a repository permission!", user.hasRepositoryPermission(repository.name));
                assertTrue("user CAN NOT view!", user.canView(repository));
@@ -2647,12 +2647,11 @@ public class PermissionsTest extends GitblitUnitTest {
 
        @Test
        public void testVisitorPersonalRepository() throws Exception {
-               RepositoryModel repository = new RepositoryModel("~test/myrepo.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("~test/myrepo.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
                UserModel user = new UserModel("visitor");
-               repository.addOwner("test");
 
                assertFalse("user HAS a repository permission!", user.hasRepositoryPermission(repository.name));
                assertFalse("user CAN view!", user.canView(repository));
@@ -2673,7 +2672,7 @@ public class PermissionsTest extends GitblitUnitTest {
 
        @Test
        public void testRegexMatching() throws Exception {
-               RepositoryModel repository = new RepositoryModel("ubercool/_my-r/e~po.git", null, null, new Date());
+               RepositoryModel repository = new RepositoryModel("ubercool/_my-r/e~po.git", null, new Date());
                repository.authorizationControl = AuthorizationControl.NAMED;
                repository.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -2704,7 +2703,7 @@ public class PermissionsTest extends GitblitUnitTest {
                user.setRepositoryPermission("[^~].*", AccessPermission.CLONE);
 
                // common
-               RepositoryModel common = new RepositoryModel("ubercool/_my-r/e~po.git", null, null, new Date());
+               RepositoryModel common = new RepositoryModel("ubercool/_my-r/e~po.git", null, new Date());
                common.authorizationControl = AuthorizationControl.NAMED;
                common.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -2725,7 +2724,7 @@ public class PermissionsTest extends GitblitUnitTest {
                assertFalse("user CAN edit!", user.canEdit(common));
 
                // personal
-               RepositoryModel personal = new RepositoryModel("~ubercool/_my-r/e~po.git", null, null, new Date());
+               RepositoryModel personal = new RepositoryModel("~ubercool/_my-r/e~po.git", null, new Date());
                personal.authorizationControl = AuthorizationControl.NAMED;
                personal.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -2748,7 +2747,7 @@ public class PermissionsTest extends GitblitUnitTest {
 
        @Test
        public void testRegexMatching2() throws Exception {
-               RepositoryModel personal = new RepositoryModel("~ubercool/_my-r/e~po.git", null, null, new Date());
+               RepositoryModel personal = new RepositoryModel("~ubercool/_my-r/e~po.git", null, new Date());
                personal.authorizationControl = AuthorizationControl.NAMED;
                personal.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -2778,7 +2777,7 @@ public class PermissionsTest extends GitblitUnitTest {
 
        @Test
        public void testRegexOrder() throws Exception {
-               RepositoryModel personal = new RepositoryModel("~ubercool/_my-r/e~po.git", null, null, new Date());
+               RepositoryModel personal = new RepositoryModel("~ubercool/_my-r/e~po.git", null, new Date());
                personal.authorizationControl = AuthorizationControl.NAMED;
                personal.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -2827,7 +2826,7 @@ public class PermissionsTest extends GitblitUnitTest {
 
        @Test
        public void testExclusion() throws Exception {
-               RepositoryModel personal = new RepositoryModel("~ubercool/_my-r/e~po.git", null, null, new Date());
+               RepositoryModel personal = new RepositoryModel("~ubercool/_my-r/e~po.git", null, new Date());
                personal.authorizationControl = AuthorizationControl.NAMED;
                personal.accessRestriction = AccessRestrictionType.VIEW;
 
@@ -2882,7 +2881,7 @@ public class PermissionsTest extends GitblitUnitTest {
 
        @Test
        public void testIsFrozen() throws Exception {
-               RepositoryModel repo = new RepositoryModel("somerepo.git", null, null, new Date());
+               RepositoryModel repo = new RepositoryModel("somerepo.git", null, new Date());
                repo.authorizationControl = AuthorizationControl.NAMED;
                repo.accessRestriction = AccessRestrictionType.NONE;
 
@@ -2900,7 +2899,7 @@ public class PermissionsTest extends GitblitUnitTest {
 
        @Test
        public void testIsBare() throws Exception {
-               RepositoryModel repo = new RepositoryModel("somerepo.git", null, null, new Date());
+               RepositoryModel repo = new RepositoryModel("somerepo.git", null, new Date());
                repo.authorizationControl = AuthorizationControl.NAMED;
                repo.accessRestriction = AccessRestrictionType.NONE;
 
@@ -2918,7 +2917,7 @@ public class PermissionsTest extends GitblitUnitTest {
 
        @Test
        public void testIsMirror() throws Exception {
-               RepositoryModel repo = new RepositoryModel("somerepo.git", null, null, new Date());
+               RepositoryModel repo = new RepositoryModel("somerepo.git", null, new Date());
                repo.authorizationControl = AuthorizationControl.NAMED;
                repo.accessRestriction = AccessRestrictionType.NONE;
 
index b782b4495ef7a9e9edd97673ac2823fca243ed92..97717d8271dae54663fa413ef5dc110fc4c6f2c6 100644 (file)
@@ -39,7 +39,7 @@ import com.gitblit.tickets.RedisTicketService;
  */
 public class RedisTicketServiceTest extends TicketServiceTest {
 
-       final RepositoryModel repo = new RepositoryModel("tickets/redis.git", null, null, null);
+       final RepositoryModel repo = new RepositoryModel("tickets/redis.git", null, null);
 
        @Override
        protected RepositoryModel getRepository() {
index 51b4671bafaf14f226d44fcba6fd74663a2e1f1b..2a48a8ba2f856ce170938558019496d280326360 100644 (file)
@@ -177,7 +177,6 @@ public class RpcTests extends GitblitUnitTest {
                RepositoryModel model = new RepositoryModel();\r
                model.name = "garbagerepo.git";\r
                model.description = "created by RpcUtils";\r
-               model.addOwner("garbage");\r
                model.accessRestriction = AccessRestrictionType.VIEW;\r
                model.authorizationControl = AuthorizationControl.AUTHENTICATED;\r
 \r
index cdb0a330cba5203548504c4f9049f6084df513e0..d3a96c8e613d1fe7f7f9fe81566e69e54d3a1be1 100644 (file)
@@ -106,9 +106,9 @@ public class UserServiceTest extends GitblitUnitTest {
                assertEquals(1, service.getAllTeamNames().size());\r
                assertEquals("admins", service.getAllTeamNames().get(0));\r
 \r
-               RepositoryModel newrepo1 = new RepositoryModel("newrepo1", null, null, null);\r
+               RepositoryModel newrepo1 = new RepositoryModel("newrepo1", null, null);\r
                newrepo1.accessRestriction = AccessRestrictionType.VIEW;\r
-               RepositoryModel NEWREPO1 = new RepositoryModel("NEWREPO1", null, null, null);\r
+               RepositoryModel NEWREPO1 = new RepositoryModel("NEWREPO1", null, null);\r
                NEWREPO1.accessRestriction = AccessRestrictionType.VIEW;\r
 \r
                // remove newrepo1 from test user\r
@@ -144,9 +144,9 @@ public class UserServiceTest extends GitblitUnitTest {
                assertTrue(user.canView(NEWREPO1));\r
 \r
                // rename the team and add new repository\r
-               RepositoryModel newrepo2 = new RepositoryModel("newrepo2", null, null, null);\r
+               RepositoryModel newrepo2 = new RepositoryModel("newrepo2", null, null);\r
                newrepo2.accessRestriction = AccessRestrictionType.VIEW;\r
-               RepositoryModel NEWREPO2 = new RepositoryModel("NEWREPO2", null, null, null);\r
+               RepositoryModel NEWREPO2 = new RepositoryModel("NEWREPO2", null, null);\r
                NEWREPO2.accessRestriction = AccessRestrictionType.VIEW;\r
 \r
                team.addRepositoryPermission(newrepo2.name);\r