2023-03-31 14:53:52 +02:00
|
|
|
package eu.dnetlib.openaire.exporter.model.dsm;
|
2022-02-04 10:12:15 +01:00
|
|
|
|
2023-03-31 14:53:52 +02:00
|
|
|
import java.util.LinkedList;
|
2022-02-04 10:12:15 +01:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Queue;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
2023-03-31 14:53:52 +02:00
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
2022-08-19 15:21:40 +02:00
|
|
|
|
2022-02-04 10:12:15 +01:00
|
|
|
@JsonAutoDetect
|
|
|
|
public class Header {
|
|
|
|
|
|
|
|
private long total;
|
|
|
|
|
|
|
|
private int page;
|
|
|
|
|
|
|
|
private int size;
|
|
|
|
|
|
|
|
private long time;
|
|
|
|
|
|
|
|
private int statusCode;
|
|
|
|
|
|
|
|
@JsonIgnore
|
2023-03-31 14:53:52 +02:00
|
|
|
private Queue<Throwable> exceptions = new LinkedList<>();
|
2022-02-04 10:12:15 +01:00
|
|
|
|
|
|
|
public static Header newInsance() {
|
|
|
|
return new Header();
|
|
|
|
}
|
|
|
|
|
2022-08-19 15:21:40 +02:00
|
|
|
public Header() {}
|
2022-02-04 10:12:15 +01:00
|
|
|
|
|
|
|
public long getTime() {
|
|
|
|
return time;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Header setTime(final long time) {
|
|
|
|
this.time = time;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getStatusCode() {
|
|
|
|
return statusCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Header setStatusCode(final int statusCode) {
|
|
|
|
this.statusCode = statusCode;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getTotal() {
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getPage() {
|
|
|
|
return page;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getSize() {
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Header setPage(final int page) {
|
|
|
|
this.page = page;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Header setSize(final int size) {
|
|
|
|
this.size = size;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Header setTotal(final long total) {
|
|
|
|
this.total = total;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Queue<Throwable> getExceptions() {
|
|
|
|
return exceptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Header setExceptions(final Queue<Throwable> exceptions) {
|
|
|
|
this.exceptions = exceptions;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<String> getErrors() {
|
|
|
|
return getExceptions().stream()
|
2022-08-19 15:21:40 +02:00
|
|
|
.map(Throwable::getMessage)
|
|
|
|
.collect(Collectors.toList());
|
2022-02-04 10:12:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public String toJson() {
|
2023-03-31 14:53:52 +02:00
|
|
|
try {
|
|
|
|
return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this);
|
|
|
|
} catch (final JsonProcessingException e) {
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
}
|
2022-02-04 10:12:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|