| 1 | package edu.ucsb.cs156.frontiers.jobs; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.frontiers.entities.Course; | |
| 4 | import edu.ucsb.cs156.frontiers.services.GithubTeamService; | |
| 5 | import edu.ucsb.cs156.frontiers.services.jobs.JobContext; | |
| 6 | import edu.ucsb.cs156.frontiers.services.jobs.JobContextConsumer; | |
| 7 | import lombok.Builder; | |
| 8 | ||
| 9 | @Builder | |
| 10 | public class DeleteTeamMemberFromGithubJob implements JobContextConsumer { | |
| 11 | String memberGithubLogin; | |
| 12 | Integer githubTeamId; | |
| 13 | Course course; | |
| 14 | GithubTeamService githubTeamService; | |
| 15 | ||
| 16 | @Override | |
| 17 | public Course getCourse() { | |
| 18 |
1
1. getCourse : replaced return value with null for edu/ucsb/cs156/frontiers/jobs/DeleteTeamMemberFromGithubJob::getCourse → KILLED |
return this.course; |
| 19 | } | |
| 20 | ||
| 21 | @Override | |
| 22 | public void accept(JobContext ctx) throws Exception { | |
| 23 | ctx.log( | |
| 24 | "Starting delete team member from GitHub job for team ID " | |
| 25 | + githubTeamId | |
| 26 | + " member " | |
| 27 | + memberGithubLogin); | |
| 28 | ||
| 29 |
1
1. accept : negated conditional → KILLED |
if (githubTeamId == null) { |
| 30 | ctx.log("ERROR: Team has no GitHub team ID"); | |
| 31 | return; | |
| 32 | } | |
| 33 | ||
| 34 |
1
1. accept : negated conditional → KILLED |
if (memberGithubLogin == null) { |
| 35 | ctx.log("ERROR: Team member has no GitHub login"); | |
| 36 | return; | |
| 37 | } | |
| 38 | ||
| 39 |
2
1. accept : negated conditional → KILLED 2. accept : negated conditional → KILLED |
if (course.getOrgName() == null || course.getInstallationId() == null) { |
| 40 | ctx.log("ERROR: Course has no linked GitHub organization"); | |
| 41 | return; | |
| 42 | } | |
| 43 | // Get the organization id | |
| 44 | Integer orgId = null; | |
| 45 | try { | |
| 46 | orgId = githubTeamService.getOrgId(course.getOrgName(), course); | |
| 47 | ||
| 48 | } catch (Exception e) { | |
| 49 | ctx.log( | |
| 50 | "ERROR: Failed to get organization ID for org: " | |
| 51 | + course.getOrgName() | |
| 52 | + " - " | |
| 53 | + e.getMessage()); | |
| 54 | return; | |
| 55 | } | |
| 56 | ||
| 57 | try { | |
| 58 |
1
1. accept : removed call to edu/ucsb/cs156/frontiers/services/GithubTeamService::removeMemberFromGithubTeam → KILLED |
githubTeamService.removeMemberFromGithubTeam(orgId, memberGithubLogin, githubTeamId, course); |
| 59 | ctx.log("Successfully removed user from GitHub team"); | |
| 60 | } catch (Exception e) { | |
| 61 | ctx.log("ERROR: Failed to remove user from GitHub team: " + e.getMessage()); | |
| 62 | } | |
| 63 | ||
| 64 | ctx.log("Done"); | |
| 65 | } | |
| 66 | } | |
Mutations | ||
| 18 |
1.1 |
|
| 29 |
1.1 |
|
| 34 |
1.1 |
|
| 39 |
1.1 2.2 |
|
| 58 |
1.1 |