1 |
50561
|
claudio.at
|
package eu.dnetlib.openaire.exporter.datasource.clients;
|
2 |
|
|
|
3 |
|
|
import java.util.List;
|
4 |
|
|
import java.util.Queue;
|
5 |
|
|
|
6 |
|
|
import com.google.common.collect.Lists;
|
7 |
|
|
import eu.dnetlib.openaire.exporter.model.DatasourceResponse;
|
8 |
|
|
import eu.dnetlib.openaire.exporter.model.Header;
|
9 |
|
|
import eu.dnetlib.openaire.exporter.model.datasource.ApiDetails;
|
10 |
|
|
import eu.dnetlib.openaire.exporter.model.ApiDetailsResponse;
|
11 |
|
|
import eu.dnetlib.openaire.exporter.model.datasource.DatasourceInfo;
|
12 |
|
|
|
13 |
|
|
public class ResponseUtils {
|
14 |
|
|
|
15 |
|
|
public static DatasourceResponse datasourceResponse(final List<DatasourceInfo> datasourceInfo, final Queue<Throwable> errors, final long total) {
|
16 |
|
|
final DatasourceResponse rsp = new DatasourceResponse().setDatasourceInfo(datasourceInfo);
|
17 |
|
|
rsp.setHeader(getHeader(errors, total));
|
18 |
|
|
return rsp;
|
19 |
|
|
}
|
20 |
|
|
|
21 |
|
|
public static ApiDetailsResponse apiResponse(final List<ApiDetails> api, final long total) {
|
22 |
|
|
final ApiDetailsResponse rsp = new ApiDetailsResponse().setApi(api);
|
23 |
|
|
rsp.setHeader(getHeader(Lists.newLinkedList(), total));
|
24 |
|
|
return rsp;
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
private static Header getHeader(final Queue<Throwable> errors, final long total) {
|
28 |
|
|
return Header.newInsance()
|
29 |
|
|
.setExceptions(errors)
|
30 |
|
|
.setTotal(total);
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
}
|