Package com.gitblit.models

Examples of com.gitblit.models.TeamModel


  public void testTeamAdministration() throws IOException {
    List<TeamModel> teams = RpcUtils.getTeams(url, account, password.toCharArray());
    assertEquals(1, teams.size());

    // Create the A-Team
    TeamModel aTeam = new TeamModel("A-Team");
    aTeam.users.add("admin");
    aTeam.addRepositoryPermission("helloworld.git");
    assertTrue(RpcUtils.createTeam(aTeam, url, account, password.toCharArray()));

    aTeam = null;
    teams = RpcUtils.getTeams(url, account, password.toCharArray());
    assertEquals(2, teams.size());
    for (TeamModel team : teams) {
      if (team.name.equals("A-Team")) {
        aTeam = team;
        break;
      }
    }
    assertNotNull(aTeam);
    assertTrue(aTeam.hasUser("admin"));
    assertTrue(aTeam.hasRepositoryPermission("helloworld.git"));

    RepositoryModel helloworld = null;
    Map<String, RepositoryModel> repositories = RpcUtils.getRepositories(url, account,
        password.toCharArray());
    for (RepositoryModel repository : repositories.values()) {
View Full Code Here


      if (!gitblit.deleteUser(model.username)) {
        response.setStatus(failureCode);
      }
    } else if (RpcRequest.CREATE_TEAM.equals(reqType)) {
      // create team
      TeamModel model = deserialize(request, response, TeamModel.class);
      try {
        gitblit.addTeam(model);
      } catch (GitBlitException e) {
        response.setStatus(failureCode);
      }
    } else if (RpcRequest.EDIT_TEAM.equals(reqType)) {
      // edit team
      TeamModel model = deserialize(request, response, TeamModel.class);
      // name parameter specifies original team name in event of rename
      String teamname = objectName;
      if (teamname == null) {
        teamname = model.name;
      }
      try {
        gitblit.reviseTeam(teamname, model);
      } catch (GitBlitException e) {
        response.setStatus(failureCode);
      }
    } else if (RpcRequest.DELETE_TEAM.equals(reqType)) {
      // delete team
      TeamModel model = deserialize(request, response, TeamModel.class);
      if (!gitblit.deleteTeam(model.name)) {
        response.setStatus(failureCode);
      }
    } else if (RpcRequest.LIST_REPOSITORY_MEMBERS.equals(reqType)) {
      // get repository members
View Full Code Here

          return;
        }
        List<String> teamnames = userManager.getAllTeamNames();
        List<TeamModel> teams = new ArrayList<TeamModel>();
        for (String teamname : teamnames) {
          TeamModel user = userManager.getTeamModel(teamname);
          teams.add(user);
        }
        result = teams;
      } else if (FederationRequest.PULL_SCRIPTS.equals(reqType)) {
        // pull scripts
View Full Code Here

    // grant origin's team list clone permission to fork
    List<String> teams = repositoryManager.getRepositoryTeams(repository);
    List<TeamModel> cloneTeams = new ArrayList<TeamModel>();
    for (String name : teams) {
      TeamModel cloneTeam = userManager.getTeamModel(name);
      if (cloneTeam.canClone(repository) && !cloneTeam.canClone(cloneModel)) {
        // origin team can't yet clone fork, grant explicit clone access
        cloneTeam.setRepositoryPermission(cloneName, AccessPermission.CLONE);
      }
      cloneTeams.add(cloneTeam);
    }
    userManager.updateTeamModels(cloneTeams);
View Full Code Here

    }

    // Team Scripts
    if (repository != null) {
      for (String teamname : getPermittedTeamnames(repository)) {
        TeamModel team = getTeamModel(teamname);
        if (!ArrayUtils.isEmpty(team.preReceiveScripts)) {
          scripts.addAll(team.preReceiveScripts);
        }
      }
    }
View Full Code Here

      }
    }
    // Team Scripts
    if (repository != null) {
      for (String teamname : getPermittedTeamnames(repository)) {
        TeamModel team = getTeamModel(teamname);
        if (!ArrayUtils.isEmpty(team.postReceiveScripts)) {
          scripts.addAll(team.postReceiveScripts);
        }
      }
    }
View Full Code Here

        }

        Iterator<String> selectedTeams = teams.getSelectedChoices();
        userModel.teams.clear();
        while (selectedTeams.hasNext()) {
          TeamModel team = app().users().getTeamModel(selectedTeams.next());
          if (team == null) {
            continue;
          }
          userModel.teams.add(team);
        }
View Full Code Here

   * @return a team object or null
   * @since 0.8.0
   */
  @Override
  public TeamModel getTeamModel(String teamname) {
    TeamModel team = userService.getTeamModel(teamname);
    return team;
  }
View Full Code Here

      List<String> teams = StringUtils.getStringsFromValue(team, ",");

      // need TeamModels first
      List<TeamModel> teamModels = new ArrayList<TeamModel>();
      for (String name : teams) {
        TeamModel teamModel = app().users().getTeamModel(name);
        if (teamModel != null) {
          teamModels.add(teamModel);
        }
      }

      // brute-force our way through finding the matching models
      for (ProjectModel projectModel : availableModels) {
        for (String repositoryName : projectModel.repositories) {
          for (TeamModel teamModel : teamModels) {
            if (teamModel.hasRepositoryPermission(repositoryName)) {
              models.add(projectModel);
            }
          }
        }
      }
View Full Code Here

      List<String> teams = StringUtils.getStringsFromValue(team, ",");

      // need TeamModels first
      List<TeamModel> teamModels = new ArrayList<TeamModel>();
      for (String name : teams) {
        TeamModel teamModel = app().users().getTeamModel(name);
        if (teamModel != null) {
          teamModels.add(teamModel);
        }
      }

      // brute-force our way through finding the matching models
      for (RepositoryModel repositoryModel : availableModels) {
        for (TeamModel teamModel : teamModels) {
          if (teamModel.hasRepositoryPermission(repositoryModel.name)) {
            models.add(repositoryModel);
          }
        }
      }
    }
View Full Code Here

TOP

Related Classes of com.gitblit.models.TeamModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.