You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.4 KiB
Java
72 lines
2.4 KiB
Java
package eu.openaire.urls_controller.controllers;
|
|
|
|
import eu.openaire.urls_controller.models.UrlToCheck;
|
|
import eu.openaire.urls_controller.payloads.responces.UrlsResponse;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
@RestController
|
|
@RequestMapping("/urls")
|
|
public class UrlController {
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(UrlController.class);
|
|
|
|
|
|
public UrlController() {
|
|
|
|
}
|
|
|
|
|
|
@GetMapping("")
|
|
public ResponseEntity<?> getUrls() {
|
|
|
|
List<UrlToCheck> urlsToCheck = new ArrayList<>();
|
|
|
|
|
|
// TODO - Retrieve the ID-URL pairs from the database.
|
|
|
|
// For now, we give static data.
|
|
urlsToCheck.add(new UrlToCheck("50|dedup_wf_001::173a4e29249d4a67e72148ff50a88968", "http://dx.doi.org/10.1590/s0034-76122012000200012"));
|
|
urlsToCheck.add(new UrlToCheck("50|dedup_wf_001::220cb83d8a6e7a90ac4ac72feb030700", "https://doaj.org/toc/2214-9147"));
|
|
urlsToCheck.add(new UrlToCheck("50|dedup_wf_001::2b29092d3ed25d7ccfac894974e0915e", "http://www.plantintroduction.org/index.php/pi/article/view/1201"));
|
|
urlsToCheck.add(new UrlToCheck("50|dedup_wf_001::2fed1ea2149efd0d5a7837240a4aaf71", "http://europepmc.org/articles/pmc2882784?pdf=render"));
|
|
urlsToCheck.add(new UrlToCheck("50|dedup_wf_001::180e60bbb541a9b9a9313779887da9cf", "http://dx.doi.org/10.1051/e3sconf/202016405016"));
|
|
|
|
logger.debug("ID-URL pairs to return:\n" + urlsToCheck);
|
|
|
|
return ResponseEntity.status(200).header("Content-Type", "application/json").body(new UrlsResponse(urlsToCheck).toString());
|
|
}
|
|
|
|
|
|
|
|
@PostMapping("")
|
|
// TODO - Add authorization to edit the database.
|
|
public ResponseEntity<?> addResults() {
|
|
|
|
UrlToCheck urlToCheck = new UrlToCheck();
|
|
|
|
List<UrlToCheck> urlsToCheck = new ArrayList<>();
|
|
|
|
|
|
// TODO - Retrieve the ID-URL pairs from the database.
|
|
|
|
// For now, we give static data.
|
|
urlsToCheck.add(new UrlToCheck("ID-1", "URL-1"));
|
|
|
|
|
|
logger.debug("ID-URL pairs to return: " + urlsToCheck);
|
|
|
|
return ResponseEntity.ok(new UrlsResponse(urlsToCheck));
|
|
}
|
|
|
|
|
|
}
|