- Update "addResults"-endpoint.

- Add "UrlsRequest.java".
- Some minor updates in "build.gradle" and "application.properties".
This commit is contained in:
Lampros Smyrnaios 2021-03-16 18:07:30 +02:00
parent 8a4376da9c
commit c6e12d3e95
4 changed files with 47 additions and 16 deletions

View File

@ -44,3 +44,7 @@ dependencies {
testImplementation group: 'org.springframework.security', name: 'spring-security-test', version: springSecurityVersion testImplementation group: 'org.springframework.security', name: 'spring-security-test', version: springSecurityVersion
testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.boot:spring-boot-starter-test'
} }
test {
useJUnitPlatform()
}

View File

@ -1,14 +1,12 @@
package eu.openaire.urls_controller.controllers; package eu.openaire.urls_controller.controllers;
import eu.openaire.urls_controller.models.UrlToCheck; import eu.openaire.urls_controller.models.UrlToCheck;
import eu.openaire.urls_controller.payloads.requests.UrlsRequest;
import eu.openaire.urls_controller.payloads.responces.UrlsResponse; import eu.openaire.urls_controller.payloads.responces.UrlsResponse;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
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.ArrayList;
import java.util.List; import java.util.List;
@ -49,22 +47,15 @@ public class UrlController {
@PostMapping("") @PostMapping("")
// TODO - Add authorization to edit the database. // TODO - Add authorization to edit the database.
public ResponseEntity<?> addResults() { public ResponseEntity<?> addResults(@RequestBody UrlsRequest urlsRequest) {
UrlToCheck urlToCheck = new UrlToCheck(); logger.debug(urlsRequest.toString());
List<UrlToCheck> urlsToCheck = new ArrayList<>();
// TODO - Retrieve the ID-URL pairs from the database. // TODO - Add data in 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().build();
return ResponseEntity.ok(new UrlsResponse(urlsToCheck));
} }

View File

@ -0,0 +1,36 @@
package eu.openaire.urls_controller.payloads.requests;
import eu.openaire.urls_controller.models.Payload;
import java.util.List;
public class UrlsRequest {
private List<Payload> payloads;
public void UrlsResponse() {
}
public void UrlsResponse(List<Payload> payloads) {
this.payloads = payloads;
}
public UrlsRequest get() {
return this;
}
public List<Payload> getUrlsToCheck() {
return payloads;
}
public void setUrlsToCheck(List<Payload> payloads) {
this.payloads = payloads;
}
@Override
public String toString() {
return "UrlsRequest{" +
"payloads=" + payloads +
'}';
}
}

View File

@ -4,7 +4,7 @@
#server.ssl.key-store = src/main/resources/keystore.p12 #server.ssl.key-store = src/main/resources/keystore.p12
#server.ssl.key-store-type = PKCS12 #server.ssl.key-store-type = PKCS12
#server.ssl.key-alias = tomcat #server.ssl.key-alias = tomcat
#server.ssl.key-store-password = rent_project #server.ssl.key-store-password = urls_controller_project
#server.tomcat.remoteip.remote-ip-header = x-your-remote-ip-header #server.tomcat.remoteip.remote-ip-header = x-your-remote-ip-header
#server.tomcat.remoteip.protocol-header = x-your-protocol-header #server.tomcat.remoteip.protocol-header = x-your-protocol-header
#server.error.include-stacktrace=never #server.error.include-stacktrace=never