- Update the "getUrls" and "getTestUrls" endpoints to take the data from the workers, in http-request-parameters instead of the http-body.
- Fix tasksLimit-check. - Code cleanup.
This commit is contained in:
parent
e2cc320baf
commit
d20fcf9cce
|
@ -6,11 +6,10 @@ buildscript {
|
|||
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.4.5'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'io.spring.dependency-management'
|
||||
|
||||
group = 'eu.openaire.urls_controller'
|
||||
version = '0.0.1-SNAPSHOT'
|
||||
|
|
|
@ -3,7 +3,6 @@ package eu.openaire.urls_controller.controllers;
|
|||
import com.google.common.collect.HashMultimap;
|
||||
import eu.openaire.urls_controller.models.Assignment;
|
||||
import eu.openaire.urls_controller.models.Task;
|
||||
import eu.openaire.urls_controller.payloads.requests.WorkerRequest;
|
||||
import eu.openaire.urls_controller.payloads.responces.AssignmentResponse;
|
||||
import eu.openaire.urls_controller.util.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -11,6 +10,7 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -28,10 +28,7 @@ public class UrlController {
|
|||
|
||||
|
||||
@GetMapping("")
|
||||
public ResponseEntity<?> getUrls(WorkerRequest workerRequest) {
|
||||
|
||||
String workerId = workerRequest.getWorkerId();
|
||||
int tasksLimit = workerRequest.getTasksLimit();
|
||||
public ResponseEntity<?> getUrls(@RequestParam String workerId, @RequestParam int tasksLimit) {
|
||||
|
||||
List<Task> tasks = new ArrayList<>();
|
||||
|
||||
|
@ -46,10 +43,7 @@ public class UrlController {
|
|||
|
||||
|
||||
@GetMapping("test")
|
||||
public ResponseEntity<?> getTestUrls(WorkerRequest workerRequest) {
|
||||
|
||||
String workerId = workerRequest.getWorkerId();
|
||||
int tasksLimit = workerRequest.getTasksLimit();
|
||||
public ResponseEntity<?> getTestUrls(@RequestParam String workerId, @RequestParam int tasksLimit) {
|
||||
|
||||
List<Task> tasks = new ArrayList<>();
|
||||
new FileUtils(); // Find the input file.
|
||||
|
@ -72,7 +66,7 @@ public class UrlController {
|
|||
|
||||
for ( Map.Entry<String,String> pair : pairs )
|
||||
{
|
||||
if ( tasks.size() > tasksLimit ) {
|
||||
if ( tasks.size() >= tasksLimit ) {
|
||||
tasksLimitReached = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
package eu.openaire.urls_controller.payloads.requests;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"workerId",
|
||||
"tasksLimit"
|
||||
})
|
||||
public class WorkerRequest {
|
||||
|
||||
@JsonProperty("workerId")
|
||||
private String workerId;
|
||||
|
||||
@JsonProperty("tasksLimit")
|
||||
private int tasksLimit;
|
||||
|
||||
public String getWorkerId() {
|
||||
return workerId;
|
||||
}
|
||||
|
||||
public void setWorkerId(String workerId) {
|
||||
this.workerId = workerId;
|
||||
}
|
||||
|
||||
public int getTasksLimit() {
|
||||
return tasksLimit;
|
||||
}
|
||||
|
||||
public void setTasksLimit(int tasksLimit) {
|
||||
this.tasksLimit = tasksLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WorkerRequest{" +
|
||||
"id='" + workerId + '\'' +
|
||||
", tasksLimit=" + tasksLimit +
|
||||
'}';
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue