Class GithubTeamService

java.lang.Object
edu.ucsb.cs156.frontiers.services.GithubTeamService

@Service public class GithubTeamService extends Object
  • Constructor Details

    • GithubTeamService

      public GithubTeamService(JwtService jwtService, com.fasterxml.jackson.databind.ObjectMapper objectMapper, org.springframework.boot.web.client.RestTemplateBuilder builder)
  • Method Details

    • createOrGetTeamId

      public Integer createOrGetTeamId(Team team, Course course) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException
      Creates a team on GitHub if it doesn't exist, or returns the existing team ID.
      Parameters:
      team - The team to create
      course - The course containing the organization
      Returns:
      The GitHub team ID
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - if there is an error processing JSON
      NoSuchAlgorithmException - if there is an algorithm error
      InvalidKeySpecException - if there is a key specification error
    • getOrgId

      public Integer getOrgId(String orgName, Course course) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException
      Get the org id, given the org name.

      Note: in the future, it would be better to cache this value in the Course row in the database at the time the Github App is linked to the org, since it doesn't change.

      Parameters:
      orgName -
      course -
      Returns:
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
      NoSuchAlgorithmException
      InvalidKeySpecException
    • getTeamId

      public Integer getTeamId(String teamName, Course course) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException
      Gets the team ID for a team name, returns null if team doesn't exist.
      Parameters:
      teamName - The name of the team
      course - The course containing the organization
      Returns:
      The GitHub team ID or null if not found
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - if there is an error processing JSON
      NoSuchAlgorithmException - if there is an algorithm error
      InvalidKeySpecException - if there is a key specification error
    • getTeamMembershipStatus

      public TeamStatus getTeamMembershipStatus(String githubLogin, Integer teamId, Course course) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException
      Gets the current team membership status for a user.
      Parameters:
      githubLogin - The GitHub login of the user
      teamId - The GitHub team ID
      course - The course containing the organization
      Returns:
      The team status of the user
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - if there is an error processing JSON
      NoSuchAlgorithmException - if there is an algorithm error
      InvalidKeySpecException - if there is a key specification error
    • addMemberToGithubTeam

      public TeamStatus addMemberToGithubTeam(String githubLogin, Integer teamId, String role, Course course, Integer orgId) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException
      Adds a member to a GitHub team.
      Parameters:
      githubLogin - The GitHub login of the user to add
      role - The role to assign ("member" or "maintainer")
      course - The course containing the organization
      teamSlug - The GitHub team slug (name)
      Returns:
      The resulting team status
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - if there is an error processing JSON
      NoSuchAlgorithmException - if there is an algorithm error
      InvalidKeySpecException - if there is a key specification error