James Moger
2012-10-22 ec7ac2149ba8603ff1455c948c07037bf6ee030c
src/com/gitblit/GitBlit.java
@@ -78,12 +78,14 @@
import com.gitblit.Constants.FederationRequest;
import com.gitblit.Constants.FederationStrategy;
import com.gitblit.Constants.FederationToken;
import com.gitblit.Constants.RegistrantType;
import com.gitblit.models.FederationModel;
import com.gitblit.models.FederationProposal;
import com.gitblit.models.FederationSet;
import com.gitblit.models.ForkModel;
import com.gitblit.models.Metric;
import com.gitblit.models.ProjectModel;
import com.gitblit.models.RegistrantAccessPermission;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.SearchResult;
import com.gitblit.models.ServerSettings;
@@ -630,12 +632,44 @@
   }
   /**
    * Returns the list of all users who are allowed to bypass the access
    * restriction placed on the specified repository.
    * Returns the list of users and their access permissions for the specified repository.
    *
    * @param repository
    * @return a list of User-AccessPermission tuples
    */
   public List<RegistrantAccessPermission> getUserAccessPermissions(RepositoryModel repository) {
      List<RegistrantAccessPermission> permissions = new ArrayList<RegistrantAccessPermission>();
      for (String user : userService.getUsernamesForRepositoryRole(repository.name)) {
         AccessPermission ap = userService.getUserModel(user).getRepositoryPermission(repository);
         permissions.add(new RegistrantAccessPermission(user, ap, RegistrantType.USER));
      }
      return permissions;
   }
   /**
    * Sets the access permissions to the specified repository for the specified users.
    *
    * @param repository
    * @param permissions
    * @return true if the user models have been updated
    */
   public boolean setUserAccessPermissions(RepositoryModel repository, Collection<RegistrantAccessPermission> permissions) {
      List<UserModel> users = new ArrayList<UserModel>();
      for (RegistrantAccessPermission up : permissions) {
         UserModel user = userService.getUserModel(up.registrant);
         user.setRepositoryPermission(repository.name, up.permission);
         users.add(user);
      }
      return userService.updateUserModels(users);
   }
   /**
    * Returns the list of all users who have an explicit access permission
    * for the specified repository.
    * 
    * @see IUserService.getUsernamesForRepositoryRole(String)
    * @param repository
    * @return list of all usernames that can bypass the access restriction
    * @return list of all usernames that have an access permission for the repository
    */
   public List<String> getRepositoryUsers(RepositoryModel repository) {
      return userService.getUsernamesForRepositoryRole(repository.name);
@@ -652,7 +686,9 @@
    */
   @Deprecated
   public boolean setRepositoryUsers(RepositoryModel repository, List<String> repositoryUsers) {
      return userService.setUsernamesForRepositoryRole(repository.name, repositoryUsers);
      // rejects all changes since 1.2.0 because this would elevate
      // all discrete access permissions to RW+
      return false;
   }
   /**
@@ -726,14 +762,46 @@
   public TeamModel getTeamModel(String teamname) {
      return userService.getTeamModel(teamname);
   }
   /**
    * Returns the list of all teams who are allowed to bypass the access
    * restriction placed on the specified repository.
    * Returns the list of teams and their access permissions for the specified repository.
    *
    * @param repository
    * @return a list of Team-AccessPermission tuples
    */
   public List<RegistrantAccessPermission> getTeamAccessPermissions(RepositoryModel repository) {
      List<RegistrantAccessPermission> permissions = new ArrayList<RegistrantAccessPermission>();
      for (String team : userService.getTeamnamesForRepositoryRole(repository.name)) {
         AccessPermission ap = userService.getTeamModel(team).getRepositoryPermission(repository);
         permissions.add(new RegistrantAccessPermission(team, ap, RegistrantType.TEAM));
      }
      return permissions;
   }
   /**
    * Sets the access permissions to the specified repository for the specified teams.
    *
    * @param repository
    * @param permissions
    * @return true if the team models have been updated
    */
   public boolean setTeamAccessPermissions(RepositoryModel repository, Collection<RegistrantAccessPermission> permissions) {
      List<TeamModel> teams = new ArrayList<TeamModel>();
      for (RegistrantAccessPermission tp : permissions) {
         TeamModel team = userService.getTeamModel(tp.registrant);
         team.setRepositoryPermission(repository.name, tp.permission);
         teams.add(team);
      }
      return userService.updateTeamModels(teams);
   }
   /**
    * Returns the list of all teams who have an explicit access permission for
    * the specified repository.
    * 
    * @see IUserService.getTeamnamesForRepositoryRole(String)
    * @param repository
    * @return list of all teamnames that can bypass the access restriction
    * @return list of all teamnames with explicit access permissions to the repository
    */
   public List<String> getRepositoryTeams(RepositoryModel repository) {
      return userService.getTeamnamesForRepositoryRole(repository.name);
@@ -750,7 +818,9 @@
    */
   @Deprecated
   public boolean setRepositoryTeams(RepositoryModel repository, List<String> repositoryTeams) {
      return userService.setTeamnamesForRepositoryRole(repository.name, repositoryTeams);
      // rejects all changes since 1.2.0 because this would elevate
      // all discrete access permissions to RW+
      return false;
   }
   /**