| 1 | package edu.ucsb.cs.scaffold.controller; | |
| 2 | ||
| 3 | import edu.ucsb.cs.scaffold.entity.PlInstance; | |
| 4 | import edu.ucsb.cs.scaffold.entity.PlRepo; | |
| 5 | import edu.ucsb.cs.scaffold.errors.EntityNotFoundException; | |
| 6 | import edu.ucsb.cs.scaffold.repository.PlInstanceRepository; | |
| 7 | import edu.ucsb.cs.scaffold.repository.PlRepoRepository; | |
| 8 | import io.swagger.v3.oas.annotations.Operation; | |
| 9 | import io.swagger.v3.oas.annotations.Parameter; | |
| 10 | import io.swagger.v3.oas.annotations.tags.Tag; | |
| 11 | import java.util.List; | |
| 12 | import lombok.extern.slf4j.Slf4j; | |
| 13 | import org.springframework.beans.factory.annotation.Autowired; | |
| 14 | import org.springframework.security.access.prepost.PreAuthorize; | |
| 15 | import org.springframework.web.bind.annotation.GetMapping; | |
| 16 | import org.springframework.web.bind.annotation.RequestMapping; | |
| 17 | import org.springframework.web.bind.annotation.RequestParam; | |
| 18 | import org.springframework.web.bind.annotation.RestController; | |
| 19 | ||
| 20 | /** | |
| 21 | * Read-only: PlInstances are created, updated, and deleted by the SyncPlRepo job (issues #45/#47), | |
| 22 | * which mirrors the repo's courseInstances directory on GitHub — not by POST/DELETE endpoints. | |
| 23 | */ | |
| 24 | @Tag(name = "PlInstance") | |
| 25 | @RequestMapping("/api/plinstance") | |
| 26 | @RestController | |
| 27 | @Slf4j | |
| 28 | public class PLInstanceController extends ApiController { | |
| 29 | ||
| 30 | @Autowired private PlInstanceRepository plInstanceRepository; | |
| 31 | ||
| 32 | @Autowired private PlRepoRepository plRepoRepository; | |
| 33 | ||
| 34 | @Operation(summary = "List all PlInstances") | |
| 35 | @PreAuthorize("hasRole('ROLE_ADMIN') || hasRole('ROLE_INSTRUCTOR')") | |
| 36 | @GetMapping("/all") | |
| 37 | public Iterable<PlInstance> allPlInstances() { | |
| 38 |
1
1. allPlInstances : replaced return value with Collections.emptyList for edu/ucsb/cs/scaffold/controller/PLInstanceController::allPlInstances → KILLED |
return plInstanceRepository.findAll(); |
| 39 | } | |
| 40 | ||
| 41 | @Operation(summary = "List all PlInstances for a PlRepo") | |
| 42 | @PreAuthorize("hasRole('ROLE_ADMIN') || hasRole('ROLE_INSTRUCTOR')") | |
| 43 | @GetMapping("") | |
| 44 | public List<PlInstance> allPlInstancesForRepo( | |
| 45 | @Parameter(name = "plrepoId") @RequestParam Long plrepoId) { | |
| 46 |
1
1. allPlInstancesForRepo : removed call to edu/ucsb/cs/scaffold/controller/PLInstanceController::ensurePlRepoExists → KILLED |
ensurePlRepoExists(plrepoId); |
| 47 |
1
1. allPlInstancesForRepo : replaced return value with Collections.emptyList for edu/ucsb/cs/scaffold/controller/PLInstanceController::allPlInstancesForRepo → KILLED |
return plInstanceRepository.findByPlRepoId(plrepoId); |
| 48 | } | |
| 49 | ||
| 50 | private void ensurePlRepoExists(Long plRepoId) { | |
| 51 | plRepoRepository | |
| 52 | .findById(plRepoId) | |
| 53 |
1
1. lambda$ensurePlRepoExists$0 : replaced return value with null for edu/ucsb/cs/scaffold/controller/PLInstanceController::lambda$ensurePlRepoExists$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(PlRepo.class, plRepoId)); |
| 54 | } | |
| 55 | } | |
Mutations | ||
| 38 |
1.1 |
|
| 46 |
1.1 |
|
| 47 |
1.1 |
|
| 53 |
1.1 |