1 | package edu.ucsb.cs156.frontiers.controllers; | |
2 | ||
3 | import edu.ucsb.cs156.frontiers.entities.Course; | |
4 | import edu.ucsb.cs156.frontiers.errors.EntityNotFoundException; | |
5 | import edu.ucsb.cs156.frontiers.repositories.CourseRepository; | |
6 | import edu.ucsb.cs156.frontiers.services.GithubGraphQLService; | |
7 | import io.swagger.v3.oas.annotations.Operation; | |
8 | import io.swagger.v3.oas.annotations.Parameter; | |
9 | import io.swagger.v3.oas.annotations.tags.Tag; | |
10 | import lombok.extern.slf4j.Slf4j; | |
11 | import org.springframework.beans.factory.annotation.Autowired; | |
12 | import org.springframework.security.access.prepost.PreAuthorize; | |
13 | import org.springframework.web.bind.annotation.GetMapping; | |
14 | import org.springframework.web.bind.annotation.RequestMapping; | |
15 | import org.springframework.web.bind.annotation.RequestParam; | |
16 | import org.springframework.web.bind.annotation.RestController; | |
17 | ||
18 | @Tag(name = "GithubGraphQL") | |
19 | @RequestMapping("/api/github/graphql/") | |
20 | @RestController | |
21 | @Slf4j | |
22 | public class GithubGraphQLController extends ApiController { | |
23 | ||
24 | private final GithubGraphQLService githubGraphQLService; | |
25 | private final CourseRepository courseRepository; | |
26 | ||
27 | public GithubGraphQLController( | |
28 | @Autowired GithubGraphQLService gitHubGraphQLService, | |
29 | @Autowired CourseRepository courseRepository) { | |
30 | this.githubGraphQLService = gitHubGraphQLService; | |
31 | this.courseRepository = courseRepository; | |
32 | } | |
33 | ||
34 | /** | |
35 | * Return default branch name for a given repository. | |
36 | * | |
37 | * @param courseId the id of the course whose installation is being used for credentails | |
38 | * @param owner the owner of the repository | |
39 | * @param repo the name of the repository | |
40 | * @return the default branch name | |
41 | */ | |
42 | @Operation(summary = "Get default branch name") | |
43 | @PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") | |
44 | @GetMapping("defaultBranchName") | |
45 | public String getDefaultBranchName( | |
46 | @Parameter Long courseId, @Parameter String owner, @Parameter String repo) throws Exception { | |
47 | log.info( | |
48 | "getDefaultBranchName called with courseId: {}, owner: {}, repo: {}", | |
49 | courseId, | |
50 | owner, | |
51 | repo); | |
52 | Course course = | |
53 | courseRepository | |
54 | .findById(courseId) | |
55 |
1
1. lambda$getDefaultBranchName$0 : replaced return value with null for edu/ucsb/cs156/frontiers/controllers/GithubGraphQLController::lambda$getDefaultBranchName$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(Course.class, courseId)); |
56 | ||
57 | log.info("Found course: {}", course); | |
58 | ||
59 | log.info("Current user is authorized to access course: {}", course.getId()); | |
60 | ||
61 | String result = this.githubGraphQLService.getDefaultBranchName(course, owner, repo); | |
62 | ||
63 | log.info("Result from getDefaultBranchName: {}", result); | |
64 | ||
65 |
1
1. getDefaultBranchName : replaced return value with "" for edu/ucsb/cs156/frontiers/controllers/GithubGraphQLController::getDefaultBranchName → KILLED |
return result; |
66 | } | |
67 | ||
68 | /** | |
69 | * Return default branch name for a given repository. | |
70 | * | |
71 | * @param courseId the id of the course whose installation is being used for credentails | |
72 | * @param owner the owner of the repository | |
73 | * @param repo the name of the repository | |
74 | * @return the default branch name | |
75 | */ | |
76 | @Operation(summary = "Get commits") | |
77 | @PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") | |
78 | @GetMapping("commits") | |
79 | public String getCommits( | |
80 | @Parameter Long courseId, | |
81 | @Parameter String owner, | |
82 | @Parameter String repo, | |
83 | @Parameter String branch, | |
84 | @Parameter Integer first, | |
85 | @RequestParam(name = "after", required = false) @Parameter String after) | |
86 | throws Exception { | |
87 | log.info( | |
88 | "getCommits called with courseId: {}, owner: {}, repo: {}, branch: {}, first: {}, after: {} ", | |
89 | courseId, | |
90 | owner, | |
91 | repo, | |
92 | branch, | |
93 | first, | |
94 | after); | |
95 | Course course = | |
96 | courseRepository | |
97 | .findById(courseId) | |
98 |
1
1. lambda$getCommits$1 : replaced return value with null for edu/ucsb/cs156/frontiers/controllers/GithubGraphQLController::lambda$getCommits$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(Course.class, courseId)); |
99 | ||
100 | log.info("Found course: {}", course); | |
101 | ||
102 | log.info("Current user is authorized to access course: {}", course.getId()); | |
103 | ||
104 | String result = this.githubGraphQLService.getCommits(course, owner, repo, branch, first, after); | |
105 | ||
106 | log.info("Result from getCommits: {}", result); | |
107 | ||
108 |
1
1. getCommits : replaced return value with "" for edu/ucsb/cs156/frontiers/controllers/GithubGraphQLController::getCommits → KILLED |
return result; |
109 | } | |
110 | } | |
Mutations | ||
55 |
1.1 |
|
65 |
1.1 |
|
98 |
1.1 |
|
108 |
1.1 |