1
|
package eu.dnetlib.openaire.exporter.model;
|
2
|
|
3
|
import java.util.List;
|
4
|
import java.util.Queue;
|
5
|
import java.util.stream.Collectors;
|
6
|
|
7
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
8
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
9
|
import com.google.gson.GsonBuilder;
|
10
|
import io.swagger.annotations.ApiModel;
|
11
|
|
12
|
@ApiModel
|
13
|
@JsonAutoDetect
|
14
|
public class Header {
|
15
|
|
16
|
private long total;
|
17
|
private int page;
|
18
|
private int size;
|
19
|
private long time;
|
20
|
private int statusCode;
|
21
|
private List<String> errors;
|
22
|
|
23
|
@JsonIgnore
|
24
|
private Queue<Throwable> exceptions;
|
25
|
|
26
|
public static Header newInsance() {
|
27
|
return new Header();
|
28
|
}
|
29
|
|
30
|
public Header() {
|
31
|
}
|
32
|
|
33
|
public long getTime() {
|
34
|
return time;
|
35
|
}
|
36
|
|
37
|
public Header setTime(final long time) {
|
38
|
this.time = time;
|
39
|
return this;
|
40
|
}
|
41
|
|
42
|
public int getStatusCode() {
|
43
|
return statusCode;
|
44
|
}
|
45
|
|
46
|
public Header setStatusCode(final int statusCode) {
|
47
|
this.statusCode = statusCode;
|
48
|
return this;
|
49
|
}
|
50
|
|
51
|
public long getTotal() {
|
52
|
return total;
|
53
|
}
|
54
|
|
55
|
public int getPage() {
|
56
|
return page;
|
57
|
}
|
58
|
|
59
|
public int getSize() {
|
60
|
return size;
|
61
|
}
|
62
|
|
63
|
public Header setPage(final int page) {
|
64
|
this.page = page;
|
65
|
return this;
|
66
|
}
|
67
|
|
68
|
public Header setSize(final int size) {
|
69
|
this.size = size;
|
70
|
return this;
|
71
|
}
|
72
|
|
73
|
public Header setTotal(final long total) {
|
74
|
this.total = total;
|
75
|
return this;
|
76
|
}
|
77
|
|
78
|
public Queue<Throwable> getExceptions() {
|
79
|
return exceptions;
|
80
|
}
|
81
|
|
82
|
public Header setExceptions(final Queue<Throwable> exceptions) {
|
83
|
this.exceptions = exceptions;
|
84
|
return this;
|
85
|
}
|
86
|
|
87
|
public List<String> getErrors() {
|
88
|
return getExceptions().stream()
|
89
|
.map(e -> e.getMessage())
|
90
|
.collect(Collectors.toList());
|
91
|
}
|
92
|
|
93
|
public Header setErrors(final List<String> errors) {
|
94
|
this.errors = errors;
|
95
|
return this;
|
96
|
}
|
97
|
|
98
|
public String toJson() {
|
99
|
return new GsonBuilder().setPrettyPrinting().create().toJson(this);
|
100
|
}
|
101
|
|
102
|
}
|