From 7127dfb2def0c43abb38bc363e3f76fded881bf0 Mon Sep 17 00:00:00 2001 From: James Moger Date: Wed, 11 Dec 2013 10:58:36 -0500 Subject: [PATCH] Remove deprecated methods from User and Team models Change-Id: Ief3231270e55b8e4075de45c70ee24517b05b3fc --- .../java/com/gitblit/models/TeamModel.java | 31 ---------- .../java/com/gitblit/models/UserModel.java | 58 ------------------- .../gitblit/servlet/AuthenticationFilter.java | 2 +- 3 files changed, 1 insertion(+), 90 deletions(-) diff --git a/src/main/java/com/gitblit/models/TeamModel.java b/src/main/java/com/gitblit/models/TeamModel.java index aaa3d54a..f4a484cb 100644 --- a/src/main/java/com/gitblit/models/TeamModel.java +++ b/src/main/java/com/gitblit/models/TeamModel.java @@ -30,7 +30,6 @@ import com.gitblit.Constants.AccessRestrictionType; import com.gitblit.Constants.AccountType; import com.gitblit.Constants.PermissionType; import com.gitblit.Constants.RegistrantType; -import com.gitblit.Constants.Unused; import com.gitblit.utils.StringUtils; /** @@ -64,36 +63,6 @@ public class TeamModel implements Serializable, Comparable { this.accountType = AccountType.LOCAL; } - /** - * @use hasRepositoryPermission - * @param name - * @return - */ - @Deprecated - @Unused - public boolean hasRepository(String name) { - return hasRepositoryPermission(name); - } - - @Deprecated - @Unused - public void addRepository(String name) { - addRepositoryPermission(name); - } - - @Deprecated - @Unused - public void addRepositories(Collection names) { - addRepositoryPermissions(names); - } - - @Deprecated - @Unused - public void removeRepository(String name) { - removeRepositoryPermission(name); - } - - /** * Returns a list of repository permissions for this team. * diff --git a/src/main/java/com/gitblit/models/UserModel.java b/src/main/java/com/gitblit/models/UserModel.java index 3c33bd32..6419cce9 100644 --- a/src/main/java/com/gitblit/models/UserModel.java +++ b/src/main/java/com/gitblit/models/UserModel.java @@ -34,7 +34,6 @@ import com.gitblit.Constants.AccountType; import com.gitblit.Constants.AuthorizationControl; import com.gitblit.Constants.PermissionType; import com.gitblit.Constants.RegistrantType; -import com.gitblit.Constants.Unused; import com.gitblit.utils.ArrayUtils; import com.gitblit.utils.ModelUtils; import com.gitblit.utils.StringUtils; @@ -100,57 +99,6 @@ public class UserModel implements Principal, Serializable, Comparable || accountType.isLocal(); } - /** - * This method does not take into consideration Ownership where the - * administrator has not explicitly granted access to the owner. - * - * @param repositoryName - * @return - */ - @Deprecated - public boolean canAccessRepository(String repositoryName) { - return canAdmin() || repositories.contains(repositoryName.toLowerCase()) - || hasTeamAccess(repositoryName); - } - - @Deprecated - @Unused - public boolean canAccessRepository(RepositoryModel repository) { - boolean isOwner = repository.isOwner(username); - boolean allowAuthenticated = isAuthenticated && AuthorizationControl.AUTHENTICATED.equals(repository.authorizationControl); - return canAdmin() || isOwner || repositories.contains(repository.name.toLowerCase()) - || hasTeamAccess(repository.name) || allowAuthenticated; - } - - @Deprecated - @Unused - public boolean hasTeamAccess(String repositoryName) { - for (TeamModel team : teams) { - if (team.hasRepositoryPermission(repositoryName)) { - return true; - } - } - return false; - } - - @Deprecated - @Unused - public boolean hasRepository(String name) { - return hasRepositoryPermission(name); - } - - @Deprecated - @Unused - public void addRepository(String name) { - addRepositoryPermission(name); - } - - @Deprecated - @Unused - public void removeRepository(String name) { - removeRepositoryPermission(name); - } - /** * Returns a list of repository permissions for this user exclusive of * permissions inherited from team memberships. @@ -668,12 +616,6 @@ public class UserModel implements Principal, Serializable, Comparable return nameVerified && emailVerified; } - @Deprecated - public boolean hasBranchPermission(String repositoryName, String branch) { - // Default UserModel doesn't implement branch-level security. Other Realms (i.e. Gerrit) may override this method. - return hasRepositoryPermission(repositoryName) || hasTeamRepositoryPermission(repositoryName); - } - public boolean isMyPersonalRepository(String repository) { String projectPath = StringUtils.getFirstPathElement(repository); return !StringUtils.isEmpty(projectPath) && projectPath.equalsIgnoreCase(getPersonalPath()); diff --git a/src/main/java/com/gitblit/servlet/AuthenticationFilter.java b/src/main/java/com/gitblit/servlet/AuthenticationFilter.java index 54c70141..34478662 100644 --- a/src/main/java/com/gitblit/servlet/AuthenticationFilter.java +++ b/src/main/java/com/gitblit/servlet/AuthenticationFilter.java @@ -184,7 +184,7 @@ public abstract class AuthenticationFilter implements Filter { // Gitblit does not currently use actual roles in the traditional // servlet container sense. That is the reason this is marked // deprecated, but I may want to revisit this. - return user.canAccessRepository(role); + return user.hasRepositoryPermission(role); } @Override -- 2.39.5