| 1 | package edu.ucsb.cs156.diningcachingproxy.controller; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.diningcachingproxy.services.HostCount; | |
| 4 | import edu.ucsb.cs156.diningcachingproxy.services.HostTrackingService; | |
| 5 | import edu.ucsb.cs156.diningcachingproxy.services.ResolveHostnameJobFactory; | |
| 6 | import edu.ucsb.cs156.jobs.entities.Job; | |
| 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 java.util.List; | |
| 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.PostMapping; | |
| 15 | import org.springframework.web.bind.annotation.RequestMapping; | |
| 16 | import org.springframework.web.bind.annotation.RequestParam; | |
| 17 | import org.springframework.web.bind.annotation.RestController; | |
| 18 | ||
| 19 | /** Lets an admin see every host that has sent requests through the proxy, with a count for each. */ | |
| 20 | @Tag(name = "Admin - Requesting Hosts") | |
| 21 | @RequestMapping("/api/admin/hosts") | |
| 22 | @RestController | |
| 23 | public class HostTrackingController { | |
| 24 | ||
| 25 | @Autowired private HostTrackingService hostTrackingService; | |
| 26 | @Autowired private ResolveHostnameJobFactory resolveHostnameJobFactory; | |
| 27 | ||
| 28 | @Operation(summary = "List all hosts that have sent requests through the proxy, with counts") | |
| 29 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 30 | @GetMapping("") | |
| 31 | public List<HostCount> allHosts() { | |
| 32 |
1
1. allHosts : replaced return value with Collections.emptyList for edu/ucsb/cs156/diningcachingproxy/controller/HostTrackingController::allHosts → KILLED |
return hostTrackingService.getHostCounts(); |
| 33 | } | |
| 34 | ||
| 35 | @Operation(summary = "Retry hostname resolution for one IP address") | |
| 36 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 37 | @PostMapping("/resolve") | |
| 38 | public Job resolveHostname(@Parameter(name = "ip") @RequestParam String ip) { | |
| 39 |
1
1. resolveHostname : replaced return value with null for edu/ucsb/cs156/diningcachingproxy/controller/HostTrackingController::resolveHostname → KILLED |
return resolveHostnameJobFactory.launch(ip); |
| 40 | } | |
| 41 | } | |
Mutations | ||
| 32 |
1.1 |
|
| 39 |
1.1 |