Revision 56601
Added by Katerina Iatropoulou over 4 years ago
SearchApiService.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.search.web.api; |
2 | 2 |
|
3 |
import eu.dnetlib.api.data.SearchService; |
|
3 | 4 |
import eu.dnetlib.api.data.SearchServiceException; |
4 | 5 |
import eu.dnetlib.data.search.app.SearchServiceImpl; |
5 | 6 |
import eu.dnetlib.data.search.transform.Transformer; |
... | ... | |
7 | 8 |
import eu.dnetlib.data.search.utils.cql.CQLQueryBuilder; |
8 | 9 |
import eu.dnetlib.data.search.web.utils.RequestResponseHandler; |
9 | 10 |
import eu.dnetlib.domain.data.SearchResult; |
11 |
import io.micrometer.core.annotation.Timed; |
|
10 | 12 |
import org.apache.log4j.Logger; |
11 | 13 |
import org.springframework.beans.factory.annotation.Autowired; |
12 | 14 |
import org.springframework.stereotype.Component; |
... | ... | |
34 | 36 |
private static final Logger logger = Logger.getLogger(SearchApiService.class); |
35 | 37 |
|
36 | 38 |
@Autowired |
37 |
private SearchServiceImpl searchService = null;
|
|
39 |
private SearchService searchService = null; |
|
38 | 40 |
|
39 | 41 |
@Autowired |
40 | 42 |
private SearchRegistry searchRegistry = null; |
... | ... | |
42 | 44 |
@GET |
43 | 45 |
@Path("/api/resources") |
44 | 46 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
47 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/resources"}, longTask = false) |
|
45 | 48 |
public Response fetchResources(@QueryParam("query") String query, |
46 | 49 |
@DefaultValue("0") @QueryParam("page") final int offset, |
47 | 50 |
@DefaultValue("10") @QueryParam("size") final int limit, |
... | ... | |
58 | 61 |
@GET |
59 | 62 |
@Path("/api/publications") |
60 | 63 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
64 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/publications"}, longTask = false) |
|
61 | 65 |
public Response fetchPublications(@QueryParam("q") final String keywords, |
62 | 66 |
@QueryParam("doi") final String doi, |
63 | 67 |
@QueryParam("sortBy") final String sortBy, |
... | ... | |
81 | 85 |
@GET |
82 | 86 |
@Path("/api/publications/count") |
83 | 87 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
88 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/publications/count"}, longTask = false) |
|
84 | 89 |
public Response fetchPublicationsCount(@QueryParam("q") String query, |
85 | 90 |
@QueryParam("format") final String format, |
86 | 91 |
@QueryParam("fq") final List<String> fieldQueries, |
... | ... | |
93 | 98 |
@GET |
94 | 99 |
@Path("/api/publications/{publicationid}") |
95 | 100 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
101 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/publications/{publicationid}"}, longTask = false) |
|
96 | 102 |
public Response fetchPublicationsById(@PathParam("publicationid") String publicationid, |
97 | 103 |
@QueryParam("format") final String format, |
98 | 104 |
@QueryParam("fq") final List<String> fieldQueries, |
... | ... | |
104 | 110 |
@GET |
105 | 111 |
@Path("/api/datasets") |
106 | 112 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
113 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/datasets"}, longTask = false) |
|
107 | 114 |
public Response fetchDatasets(@QueryParam("q") String keywords, |
108 | 115 |
@QueryParam("doi") final String doi, |
109 | 116 |
@QueryParam("sortBy") final String sortBy, |
... | ... | |
122 | 129 |
@GET |
123 | 130 |
@Path("/api/datasets/count") |
124 | 131 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
132 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/datasets/count"}, longTask = false) |
|
125 | 133 |
public Response fetchDatesetsCount(@QueryParam("q") String query, |
126 | 134 |
@QueryParam("format") final String format, |
127 | 135 |
@QueryParam("fq") final List<String> fieldQueries, |
... | ... | |
133 | 141 |
|
134 | 142 |
@GET |
135 | 143 |
@Path("/api/datasets/{datasetid}") |
144 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/datasets/{datasetid}"}, longTask = false) |
|
136 | 145 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
137 | 146 |
public Response fetchDatasets(@PathParam("datasetid") String datasetid, |
138 | 147 |
@QueryParam("format") final String format, |
... | ... | |
144 | 153 |
@GET |
145 | 154 |
@Path("/api/software") |
146 | 155 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
156 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/software"}, longTask = false) |
|
147 | 157 |
public Response fetchSoftware(@QueryParam("q") String keywords, |
148 | 158 |
@QueryParam("doi") final String doi, |
149 | 159 |
@QueryParam("sortBy") final String sortBy, |
... | ... | |
162 | 172 |
@GET |
163 | 173 |
@Path("/api/software/count") |
164 | 174 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
175 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/software/count"}, longTask = false) |
|
165 | 176 |
public Response fetchSoftwareCount(@QueryParam("q") String query, |
166 | 177 |
@QueryParam("format") final String format, |
167 | 178 |
@QueryParam("fq") final List<String> fieldQueries, |
... | ... | |
173 | 184 |
@GET |
174 | 185 |
@Path("/api/software/{softwareid}") |
175 | 186 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
187 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/software/{softwareid}"}, longTask = false) |
|
176 | 188 |
public Response fetchSoftware(@PathParam("softwareid") String datasetid, |
177 | 189 |
@QueryParam("format") final String format, |
178 | 190 |
@QueryParam("fq") final List<String> fieldQueries, |
... | ... | |
183 | 195 |
@GET |
184 | 196 |
@Path("/api/other") |
185 | 197 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
198 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/other"}, longTask = false) |
|
186 | 199 |
public Response fetchOther(@QueryParam("q") String keywords, |
187 | 200 |
@QueryParam("doi") final String doi, |
188 | 201 |
@QueryParam("sortBy") final String sortBy, |
... | ... | |
201 | 214 |
@GET |
202 | 215 |
@Path("/api/other/count") |
203 | 216 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
217 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/other"}, longTask = false) |
|
204 | 218 |
public Response fetchOtherCount(@QueryParam("q") String query, |
205 | 219 |
@QueryParam("format") final String format, |
206 | 220 |
@QueryParam("fq") final List<String> fieldQueries, |
... | ... | |
212 | 226 |
@GET |
213 | 227 |
@Path("/api/other/{otherid}") |
214 | 228 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
229 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/other/{otherid}"}, longTask = false) |
|
215 | 230 |
public Response fetchOther(@PathParam("otherid") String datasetid, |
216 | 231 |
@QueryParam("format") final String format, |
217 | 232 |
@QueryParam("fq") final List<String> fieldQueries, |
... | ... | |
221 | 236 |
@GET |
222 | 237 |
@Path("/api/projects") |
223 | 238 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
239 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/projects"}, longTask = false) |
|
224 | 240 |
public Response fetchProjects(@QueryParam("q") String keywords, |
225 | 241 |
@DefaultValue("0") @QueryParam("page") int offset, |
226 | 242 |
@DefaultValue("10") @QueryParam("size") int limit, |
... | ... | |
238 | 254 |
@GET |
239 | 255 |
@Path("/api/projects/count") |
240 | 256 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
257 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/projects/count"}, longTask = false) |
|
241 | 258 |
public Response fetchProjectsCount(@QueryParam("q") String query, |
242 | 259 |
@QueryParam("format") final String format, |
243 | 260 |
@QueryParam("fq") final List<String> fieldQueries, |
... | ... | |
249 | 266 |
@GET |
250 | 267 |
@Path("/api/projects/{projectid}") |
251 | 268 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
269 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/projects/{projectid}"}, longTask = false) |
|
252 | 270 |
public Response fetchProjects(@PathParam("projectid") String projectid, |
253 | 271 |
@QueryParam("format") final String format, |
254 | 272 |
@QueryParam("fq") final List<String> fieldQueries, |
... | ... | |
259 | 277 |
@GET |
260 | 278 |
@Path("/api/projects/{projectId}/publications") |
261 | 279 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
280 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/projects/{projectid}/publications"}, longTask = false) |
|
262 | 281 |
public Response fetchProjectPublications(@PathParam("projectId") String projectId, |
263 | 282 |
@DefaultValue("0") @QueryParam("page") int offset, |
264 | 283 |
@DefaultValue("10") @QueryParam("size") int limit, |
... | ... | |
273 | 292 |
@GET |
274 | 293 |
@Path("/api/projects/{projectId}/publications/count") |
275 | 294 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
295 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/projects/{projectid}/publications/count"}, longTask = false) |
|
276 | 296 |
public Response fetchProjectPublicationsCount(@PathParam("projectId") String projectId, |
277 | 297 |
@QueryParam("format") final String format, |
278 | 298 |
@QueryParam("fq") final List<String> fieldQueries, |
... | ... | |
284 | 304 |
@GET |
285 | 305 |
@Path("/api/projects/{projectId}/datasets") |
286 | 306 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
307 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/projects/{projectId}/datasets"}, longTask = false) |
|
287 | 308 |
public Response fetchProjectDatasets(@PathParam("projectId") String projectId, |
288 | 309 |
@DefaultValue("0") @QueryParam("page") int offset, |
289 | 310 |
@DefaultValue("10") @QueryParam("size") int limit, |
... | ... | |
299 | 320 |
@GET |
300 | 321 |
@Path("/api/projects/{projectId}/datasets/count") |
301 | 322 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
323 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/projects/{projectId}/datasets/count"}, longTask = false) |
|
302 | 324 |
public Response fetchProjectDatasetsCount(@PathParam("projectId") String projectId, |
303 | 325 |
@DefaultValue("0") @QueryParam("page") int offset, |
304 | 326 |
@DefaultValue("10") @QueryParam("size") int limit, |
... | ... | |
314 | 336 |
@GET |
315 | 337 |
@Path("/api/projects/{projectId}/software/count") |
316 | 338 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
339 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/projects/{projectId}/software/count"}, longTask = false) |
|
317 | 340 |
public Response fetchProjectSoftwareCount(@PathParam("projectId") String projectId, |
318 | 341 |
@DefaultValue("0") @QueryParam("page") int offset, |
319 | 342 |
@DefaultValue("10") @QueryParam("size") int limit, |
... | ... | |
327 | 350 |
@GET |
328 | 351 |
@Path("/api/projects/{projectId}/software") |
329 | 352 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
353 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/projects/{projectId}/software"}, longTask = false) |
|
330 | 354 |
public Response fetchProjectSoftware(@PathParam("projectId") String projectId, |
331 | 355 |
@DefaultValue("0") @QueryParam("page") int offset, |
332 | 356 |
@DefaultValue("10") @QueryParam("size") int limit, |
... | ... | |
341 | 365 |
@GET |
342 | 366 |
@Path("/api/projects/{projectId}/other/count") |
343 | 367 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
368 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/projects/{projectId}/other/count"}, longTask = false) |
|
344 | 369 |
public Response fetchProjectOtherCount(@PathParam("projectId") String projectId, |
345 | 370 |
@DefaultValue("0") @QueryParam("page") int offset, |
346 | 371 |
@DefaultValue("10") @QueryParam("size") int limit, |
... | ... | |
354 | 379 |
@GET |
355 | 380 |
@Path("/api/projects/{projectId}/other") |
356 | 381 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
382 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/projects/{projectId}/other"}, longTask = false) |
|
357 | 383 |
public Response fetchProjectOther(@PathParam("projectId") String projectId, |
358 | 384 |
@DefaultValue("0") @QueryParam("page") int offset, |
359 | 385 |
@DefaultValue("10") @QueryParam("size") int limit, |
... | ... | |
368 | 394 |
@GET |
369 | 395 |
@Path("/api/datasources") |
370 | 396 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
397 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/datasources"}, longTask = false) |
|
371 | 398 |
public Response fetchDatasources(@QueryParam("q") String keywords, |
372 | 399 |
@DefaultValue("0") @QueryParam("page") final int offset, |
373 | 400 |
@DefaultValue("10") @QueryParam("size") final int limit, |
... | ... | |
384 | 411 |
@GET |
385 | 412 |
@Path("/api/datasources/count") |
386 | 413 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
414 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/datasources/count"}, longTask = false) |
|
387 | 415 |
public Response fetchDatasourcesCount(@QueryParam("q") String query, |
388 | 416 |
@QueryParam("format") final String format, |
389 | 417 |
@QueryParam("fq") final List<String> fieldQueries, |
... | ... | |
395 | 423 |
@GET |
396 | 424 |
@Path("/api/datasources/{datasourceid}") |
397 | 425 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
426 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/datasources/{datasourceid}"}, longTask = false) |
|
398 | 427 |
public Response fetchDatasources(@PathParam("datasourceid") String datasourceid, |
399 | 428 |
@QueryParam("format") final String format, |
400 | 429 |
@QueryParam("fq") final List<String> fieldQueries, |
... | ... | |
406 | 435 |
@GET |
407 | 436 |
@Path("/api/organizations") |
408 | 437 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
438 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/organizations"}, longTask = false) |
|
409 | 439 |
public Response fetchOrganisations(@QueryParam("q") String keywords, |
410 | 440 |
@DefaultValue("0") @QueryParam("page") final int offset, |
411 | 441 |
@DefaultValue("10") @QueryParam("size") final int limit, |
... | ... | |
423 | 453 |
@GET |
424 | 454 |
@Path("/api/organizations/count") |
425 | 455 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
456 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/organizations/count"}, longTask = false) |
|
426 | 457 |
public Response fetchOrganizationsCount(@QueryParam("q") String query, |
427 | 458 |
@QueryParam("format") final String format, |
428 | 459 |
@QueryParam("fq") final List<String> fieldQueries, |
... | ... | |
434 | 465 |
@GET |
435 | 466 |
@Path("/api/organizations/{organizationid}") |
436 | 467 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
468 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/organizations/{organizationid}"}, longTask = false) |
|
437 | 469 |
public Response fetchOrganizations(@PathParam("organizationid") String organizationid, |
438 | 470 |
@QueryParam("format") final String format, |
439 | 471 |
@QueryParam("fq") final List<String> fieldQueries, |
... | ... | |
445 | 477 |
@GET |
446 | 478 |
@Path("/api/organizations/{organizationid}/datasources") |
447 | 479 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
480 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/organizations/{organizationid}/datasources"}, longTask = false) |
|
448 | 481 |
public Response fetchOrganizationDatasources(@PathParam("organizationid") String organizationid, |
449 | 482 |
@DefaultValue("0") @QueryParam("page") int offset, |
450 | 483 |
@DefaultValue("10") @QueryParam("size") int limit, |
... | ... | |
458 | 491 |
@GET |
459 | 492 |
@Path("/api/organizations/{organizationid}/datasources/count") |
460 | 493 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
494 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/organizations/{organizationid}/datasources/count"}, longTask = false) |
|
461 | 495 |
public Response fetchOrganizationDatasources(@PathParam("organizationid") String organizationid, |
462 | 496 |
@QueryParam("format") final String format, |
463 | 497 |
@QueryParam("fq") final List<String> fieldQueries, |
... | ... | |
470 | 504 |
@GET |
471 | 505 |
@Path("/api/organizations/{organizationid}/publications") |
472 | 506 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
507 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/organizations/{organizationid}/publications"}, longTask = false) |
|
473 | 508 |
public Response fetchOrganizationPublications(@PathParam("organizationid") String organizationid, |
474 | 509 |
@DefaultValue("0") @QueryParam("page") int offset, |
475 | 510 |
@DefaultValue("10") @QueryParam("size") int limit, |
... | ... | |
483 | 518 |
@GET |
484 | 519 |
@Path("/api/organizations/{organizationid}/publications/count") |
485 | 520 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
521 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/organizations/{organizationid}/publications/count"}, longTask = false) |
|
486 | 522 |
public Response fetchOrganizationPublicationsCount(@PathParam("organizationid") String organizationid, |
487 | 523 |
@DefaultValue("0") @QueryParam("page") int offset, |
488 | 524 |
@DefaultValue("10") @QueryParam("size") int limit, |
... | ... | |
496 | 532 |
@GET |
497 | 533 |
@Path("/api/organizations/{organizationid}/datasets") |
498 | 534 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
535 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/organizations/{organizationid}/datasets"}, longTask = false) |
|
499 | 536 |
public Response fetchOrganizationDatsets(@PathParam("organizationid") String organizationid, |
500 | 537 |
@DefaultValue("0") @QueryParam("page") int offset, |
501 | 538 |
@DefaultValue("10") @QueryParam("size") int limit, |
... | ... | |
509 | 546 |
@GET |
510 | 547 |
@Path("/api/organizations/{organizationid}/datasets/count") |
511 | 548 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
549 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/organizations/{organizationid}/datasets/count"}, longTask = false) |
|
512 | 550 |
public Response fetchOrganizationDatsetsCount(@PathParam("organizationid") String organizationid, |
513 | 551 |
@DefaultValue("0") @QueryParam("page") int offset, |
514 | 552 |
@DefaultValue("10") @QueryParam("size") int limit, |
... | ... | |
522 | 560 |
@GET |
523 | 561 |
@Path("/api/organizations/{organizationid}/projects") |
524 | 562 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
563 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/organizations/{organizationid}/projects"}, longTask = false) |
|
525 | 564 |
public Response fetchOrganizationProjects(@PathParam("organizationid") String organizationid, |
526 | 565 |
@DefaultValue("0") @QueryParam("page") int offset, |
527 | 566 |
@DefaultValue("10") @QueryParam("size") int limit, |
... | ... | |
535 | 574 |
@GET |
536 | 575 |
@Path("/api/organizations/{organizationid}/projects/count") |
537 | 576 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
577 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/organizations/{organizationid}/projects/count"}, longTask = false) |
|
538 | 578 |
public Response fetchOrganizationProjectsCount(@PathParam("organizationid") String organizationid, |
539 | 579 |
@QueryParam("format") final String format, |
540 | 580 |
@QueryParam("fq") final List<String> fieldQueries, |
... | ... | |
636 | 676 |
@GET |
637 | 677 |
@Path("/api/reports") |
638 | 678 |
@Produces(MediaType.TEXT_PLAIN) |
679 |
@Timed(value = "http.server.request.duration", extraTags = {"referer", "portal", "uri", "/rest/v2/api/reports"}, longTask = false) |
|
639 | 680 |
public Response fetchReport(@QueryParam("q") String keywords, |
640 | 681 |
@QueryParam("refine") @DefaultValue("false") boolean refine, |
641 | 682 |
@QueryParam("fields") final List<String> fields, |
... | ... | |
662 | 703 |
logger.debug("fieldQueries " + fieldQueries); |
663 | 704 |
|
664 | 705 |
try { |
665 |
SearchResult sr = searchService.newSearch(fullQuery, Locale.getDefault().toString(), fields, fieldQueries,0, 0, format, transformer,null,false);
|
|
706 |
SearchResult sr = ((SearchServiceImpl)searchService).newSearch(fullQuery, Locale.getDefault().toString(), fields, fieldQueries,0, 0, format, transformer,null,false);
|
|
666 | 707 |
logger.debug("Total number of results " + sr.getTotal()); |
667 | 708 |
|
668 | 709 |
if (sr.getTotal() > 10000) { |
... | ... | |
683 | 724 |
os.write(CSVResponseFormat.appendTitle(entity, special).getBytes()); |
684 | 725 |
} |
685 | 726 |
try { |
686 |
searchService.cursorSearch(fullQuery, fields, fieldQueries, format, transformer, os);
|
|
727 |
((SearchServiceImpl)searchService).cursorSearch(fullQuery, fields, fieldQueries, format, transformer, os);
|
|
687 | 728 |
|
688 | 729 |
} catch (SearchServiceException sse) { |
689 | 730 |
os.write(("Fail to return report. " + sse.getMessage()).getBytes()); |
... | ... | |
810 | 851 |
enhanceQueryWithEntityId(queryBuilder, entity, cleanId(entityId)); |
811 | 852 |
} |
812 | 853 |
|
854 |
/* Queries with pids are only valid with deleted by inderence marked as true */ |
|
855 |
private void resultPidQuery(StringBuilder queryBuilder, RequestResponseHandler.Entity entity, String resultPid, List<String> fieldQueries){ |
|
856 |
builtDeletedByInferenceQuery(queryBuilder); |
|
857 |
if (entity == RequestResponseHandler.Entity.ORGANIZATION) { |
|
858 |
enhanceFieldQueryWithEntityType(entity, fieldQueries); |
|
859 |
} else if (entity != RequestResponseHandler.Entity.NONE) { |
|
860 |
throw new IllegalArgumentException("Entity " + entity.toString() + " is not supported."); |
|
861 |
} |
|
862 |
enhanceQueryWithPid(queryBuilder, entity, cleanId(resultPid)); |
|
863 |
} |
|
864 |
|
|
865 |
private void builtDeletedByInferenceQuery(StringBuilder queryBuilder) { |
|
866 |
CQLQueryBuilder.appendFieldTerm(queryBuilder, CQLQueryBuilder.Operator.NONE, "deletedByInference", CQLQueryBuilder.Operator.EQUAL, "true"); |
|
867 |
} |
|
868 |
|
|
813 | 869 |
private String builtEntity2EntityRelationQuery(RequestResponseHandler.Entity entity, String relationfield, String entityId, List<String> fieldQueries){ |
814 | 870 |
StringBuilder queryBuilder = new StringBuilder(); |
815 | 871 |
//enhanceQueryWithEntityType(queryBuilder, entity); |
... | ... | |
834 | 890 |
CQLQueryBuilder.appendFieldTerm(queryBuilder, CQLQueryBuilder.Operator.AND, "objidentifier", CQLQueryBuilder.Operator.EXACT, entityId); |
835 | 891 |
} |
836 | 892 |
|
837 |
if (entity == RequestResponseHandler.Entity.PUBLICATION || entity == RequestResponseHandler.Entity.DATASET) { |
|
893 |
if (entity == RequestResponseHandler.Entity.PUBLICATION || entity == RequestResponseHandler.Entity.DATASET |
|
894 |
|| entity == RequestResponseHandler.Entity.SOFTWARE || entity == RequestResponseHandler.Entity.OTHER) { |
|
838 | 895 |
CQLQueryBuilder.appendFieldTerm(queryBuilder, CQLQueryBuilder.Operator.OR, "resultdupid", CQLQueryBuilder.Operator.EXACT, entityId); |
896 |
|
|
897 |
} else if (entity == RequestResponseHandler.Entity.ORGANIZATION) { |
|
898 |
CQLQueryBuilder.appendFieldTerm(queryBuilder, CQLQueryBuilder.Operator.OR, "organizationdupid", CQLQueryBuilder.Operator.EXACT, entityId); |
|
839 | 899 |
} |
900 |
} |
|
840 | 901 |
|
902 |
|
|
903 |
|
|
904 |
private void enhanceQueryWithPid(StringBuilder queryBuilder, RequestResponseHandler.Entity entity, String entityId) { |
|
905 |
if (entity == RequestResponseHandler.Entity.NONE) { |
|
906 |
CQLQueryBuilder.appendFieldTerm(queryBuilder, CQLQueryBuilder.Operator.AND, "resultdupid", CQLQueryBuilder.Operator.EXACT, entityId); |
|
907 |
|
|
908 |
} else if (entity == RequestResponseHandler.Entity.ORGANIZATION) { |
|
909 |
CQLQueryBuilder.appendFieldTerm(queryBuilder, CQLQueryBuilder.Operator.AND, "organizationdupid", CQLQueryBuilder.Operator.EXACT, entityId); |
|
910 |
|
|
911 |
} else { |
|
912 |
throw new IllegalArgumentException("The entity " + entity.toString() + " is not supported."); |
|
913 |
} |
|
841 | 914 |
} |
842 | 915 |
|
843 | 916 |
private void enhanceWithSortParameter(StringBuilder queryBuilder, String sortBy) { |
... | ... | |
878 | 951 |
String responseFormat = extractResponseFormat(format); |
879 | 952 |
|
880 | 953 |
try { |
881 |
SearchResult searchResult = searchService.newSearch(query, Locale.getDefault().toString(), null, fieldQueries, 0, 0, responseFormat, null, null, false);
|
|
954 |
SearchResult searchResult = ((SearchServiceImpl)searchService).newSearch(query, Locale.getDefault().toString(), null, fieldQueries, 0, 0, responseFormat, null, null, false);
|
|
882 | 955 |
return Response.status(Response.Status.OK).entity(APIResponseFormatter.createCountMeta(request, query, searchResult.getTotal(), responseFormat)).type(responseFormat).build(); |
883 | 956 |
|
884 | 957 |
} catch (SearchServiceException sse) { |
... | ... | |
900 | 973 |
type(responseType).build(); |
901 | 974 |
} |
902 | 975 |
|
903 |
SearchResult searchResult = searchService.newSearch(fullQuery, Locale.getDefault().toString(), null, fieldQueries, 0, 1, responseType, null, null, false);
|
|
976 |
SearchResult searchResult = ((SearchServiceImpl)searchService).newSearch(fullQuery, Locale.getDefault().toString(), null, fieldQueries, 0, 1, responseType, null, null, false);
|
|
904 | 977 |
|
905 | 978 |
if (searchResult.getSearchResults() == null || searchResult.getSearchResults().isEmpty() || |
906 | 979 |
searchResult.getSearchResults().size() == 0 || searchResult.getSearchResults().get(0) == null) { |
... | ... | |
930 | 1003 |
} |
931 | 1004 |
|
932 | 1005 |
try { |
933 |
SearchResult solrResults = searchService.newSearch(fullQuery, Locale.getDefault().toString(), refineFields, fieldQueries, offset, limit, responseType, transformer, null, false);
|
|
1006 |
SearchResult solrResults = ((SearchServiceImpl)searchService).newSearch(fullQuery, Locale.getDefault().toString(), refineFields, fieldQueries, offset, limit, responseType, transformer, null, false);
|
|
934 | 1007 |
long estimatedTime = System.nanoTime() - startTime; |
935 | 1008 |
logger.debug("Publications search time " + estimatedTime/1000000 + " milliseconds"); |
936 | 1009 |
return Response.status(Response.Status.OK).entity(APIResponseFormatter.createEntitiesResponse(request, entity, fullQuery, fieldQueries, solrResults, refine, responseType, special, hasTitle)).type(responseType).build(); |
... | ... | |
985 | 1058 |
@GET |
986 | 1059 |
@Path("/api/deletedByInferencePublications/{publicationid}") |
987 | 1060 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
1061 |
@Timed(value = "http.requests.portal.publicationDuplicates", longTask = false) |
|
1062 |
//TODO remove |
|
988 | 1063 |
public Response fetchDeletedByInferencePublicationsById(@PathParam("publicationid") String publicationid, |
989 | 1064 |
@QueryParam("format") final String format, |
1065 |
@QueryParam("size") final int limit, |
|
990 | 1066 |
@QueryParam("fq") final List<String> fieldQueries, |
991 | 1067 |
@Context final HttpServletRequest request) { |
992 |
return getDeletedByInferenceResponseByEntityId(request, RequestResponseHandler.Entity.PUBLICATION, publicationid, format, fieldQueries); |
|
1068 |
|
|
1069 |
return getDeletedByInferenceResponseByPid(request, RequestResponseHandler.Entity.PUBLICATION, publicationid, format, limit, fieldQueries); |
|
993 | 1070 |
} |
994 | 1071 |
|
1072 |
@GET |
|
1073 |
@Path("/api/deletedByInferenceResults/{resultPid}") |
|
1074 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
|
1075 |
@Timed(value = "http.requests.portal.publicationDuplicates", longTask = false) |
|
1076 |
public Response fetchDeletedByInferenceEntitiesById(@PathParam("resultPid") String resultPid, |
|
1077 |
@QueryParam("format") final String format, |
|
1078 |
@QueryParam("size") final int limit, |
|
1079 |
@QueryParam("fq") final List<String> fieldQueries, |
|
1080 |
@Context final HttpServletRequest request) { |
|
1081 |
|
|
1082 |
return getDeletedByInferenceResponseByPid(request, RequestResponseHandler.Entity.NONE, resultPid, format, limit, fieldQueries); |
|
1083 |
} |
|
1084 |
|
|
1085 |
|
|
1086 |
@GET |
|
1087 |
@Path("/api/deletedByInferenceOrganizations/{organizationPid}") |
|
1088 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
|
1089 |
@Timed(value = "http.requests.portal.organizationDuplicates", longTask = false) |
|
1090 |
public Response fetchDeletedByInferenceOrganizationById(@PathParam("organizationPid") String organizationPid, |
|
1091 |
@QueryParam("format") final String format, |
|
1092 |
@QueryParam("size") final int limit, |
|
1093 |
@QueryParam("fq") final List<String> fieldQueries, |
|
1094 |
@Context final HttpServletRequest request) { |
|
1095 |
|
|
1096 |
return getDeletedByInferenceResponseByPid(request, RequestResponseHandler.Entity.ORGANIZATION, organizationPid, format, limit, fieldQueries); |
|
1097 |
} |
|
1098 |
|
|
1099 |
|
|
995 | 1100 |
//Please see comment above. I wish to remove it. |
996 |
private Response getDeletedByInferenceResponseByEntityId(HttpServletRequest request, RequestResponseHandler.Entity entity, String entityId, String format, List<String> fieldQueries) {
|
|
1101 |
private Response getDeletedByInferenceResponseByPid(HttpServletRequest request, RequestResponseHandler.Entity entity, String resultPid, String format, int limit, List<String> fieldQueries) {
|
|
997 | 1102 |
String responseType = extractResponseFormat(format); |
998 | 1103 |
|
999 | 1104 |
try { |
1000 | 1105 |
StringBuilder queryBuilder = new StringBuilder(); |
1001 |
builtEntityIdQuery(queryBuilder, entity, entityId, fieldQueries);
|
|
1106 |
resultPidQuery(queryBuilder, entity, resultPid, fieldQueries);
|
|
1002 | 1107 |
String fullQuery = queryBuilder.toString(); |
1003 | 1108 |
|
1004 | 1109 |
if(fullQuery == null || fullQuery.isEmpty()) { |
... | ... | |
1007 | 1112 |
type(responseType).build(); |
1008 | 1113 |
} |
1009 | 1114 |
|
1010 |
SearchResult searchResult = searchService.newSearchWithoutFieldQueries(fullQuery, Locale.getDefault().toString(), null, fieldQueries, 0, 1, responseType, null, null, false);
|
|
1115 |
SearchResult searchResults = ((SearchServiceImpl)searchService).newSearchWithoutFieldQueries(fullQuery, Locale.getDefault().toString(), null, fieldQueries, 0, limit, responseType, null, null, false);
|
|
1011 | 1116 |
|
1012 |
if (searchResult.getSearchResults() == null || searchResult.getSearchResults().isEmpty() ||
|
|
1013 |
searchResult.getSearchResults().size() == 0 || searchResult.getSearchResults().get(0) == null) {
|
|
1117 |
if (searchResults.getSearchResults() == null || searchResults.getSearchResults().isEmpty() ||
|
|
1118 |
searchResults.getSearchResults().size() == 0 || searchResults.getSearchResults().get(0) == null) {
|
|
1014 | 1119 |
return Response.status(Response.Status.NOT_FOUND).entity(APIResponseFormatter.compose404Message(responseType, "404 - " + entity +" with id " |
1015 |
+ entityId + " not found.")).type(responseType).build();
|
|
1120 |
+ resultPid + " not found.")).type(responseType).build();
|
|
1016 | 1121 |
} |
1017 | 1122 |
|
1018 |
return Response.status(Response.Status.OK).entity(APIResponseFormatter.createEntityResponse(request, entity, searchResult.getSearchResults().get(0).toString(), responseType)).type(responseType).build(); |
|
1019 | 1123 |
|
1124 |
return Response.status(Response.Status.OK).entity(APIResponseFormatter.createEntitiesResponse(request, entity, fullQuery, null, searchResults, false, responseType, false, false)).type(responseType).build(); |
|
1125 |
|
|
1020 | 1126 |
} catch (SearchServiceException sse) { |
1021 |
logger.error("Fail to fetch "+ entity + " with id " + entityId, sse);
|
|
1022 |
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(APIResponseFormatter.compose500Message(responseType, "Fail to fetch " + entity + " with id " + entityId, sse.getMessage())).build();
|
|
1127 |
logger.error("Fail to fetch "+ entity + " with id " + resultPid, sse);
|
|
1128 |
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(APIResponseFormatter.compose500Message(responseType, "Fail to fetch " + entity + " with id " + resultPid, sse.getMessage())).build();
|
|
1023 | 1129 |
} |
1024 | 1130 |
} |
1025 | 1131 |
|
Also available in: Unified diff
Adding metrics with micrometer