forked from lsmyrnaios/UrlsController
Fix the Stats API returning simple numbers as "application/json". Now they are returned as "text/plain".
This commit is contained in:
parent
66a5b3c7da
commit
b73be6d8da
|
@ -6,6 +6,7 @@ import eu.openaire.urls_controller.services.StatsService;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -30,7 +31,7 @@ public class StatsController {
|
|||
* This endpoint returns the total number of payloads existing in the database, independently of the way they were aggregated.
|
||||
* This includes the payloads created by other pieces of software, before the PDF-Aggregation-Service was created.
|
||||
* */
|
||||
@GetMapping("getNumberOfAllPayloads")
|
||||
@GetMapping(value = "getNumberOfAllPayloads", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
public ResponseEntity<?> getNumberOfAllPayloads(boolean isCalledFromScheduler)
|
||||
{
|
||||
if ( ! isCalledFromScheduler )
|
||||
|
@ -44,7 +45,7 @@ public class StatsController {
|
|||
/**
|
||||
* This endpoint returns the number of payloads aggregated by the PDF-Aggregated-Service itself, through crawling.
|
||||
* */
|
||||
@GetMapping("getNumberOfPayloadsAggregatedByServiceThroughCrawling")
|
||||
@GetMapping(value = "getNumberOfPayloadsAggregatedByServiceThroughCrawling", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
public ResponseEntity<?> getNumberOfPayloadsAggregatedByServiceThroughCrawling(boolean isCalledFromScheduler)
|
||||
{
|
||||
if ( ! isCalledFromScheduler )
|
||||
|
@ -58,7 +59,7 @@ public class StatsController {
|
|||
/**
|
||||
* This endpoint returns the number of payloads aggregated by this Service, through BulkImport procedures with compatible datasources..
|
||||
* */
|
||||
@GetMapping("getNumberOfPayloadsAggregatedByServiceThroughBulkImport")
|
||||
@GetMapping(value = "getNumberOfPayloadsAggregatedByServiceThroughBulkImport", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
public ResponseEntity<?> getNumberOfPayloadsAggregatedByServiceThroughBulkImport(boolean isCalledFromScheduler)
|
||||
{
|
||||
if ( ! isCalledFromScheduler )
|
||||
|
@ -72,7 +73,7 @@ public class StatsController {
|
|||
/**
|
||||
* This endpoint returns the number of payloads aggregated by the PDF-Aggregated-Service itself, through crawling AND bulk-import procedures.
|
||||
* */
|
||||
@GetMapping("getNumberOfPayloadsAggregatedByService")
|
||||
@GetMapping(value = "getNumberOfPayloadsAggregatedByService", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
public ResponseEntity<?> getNumberOfPayloadsAggregatedByService(boolean isCalledFromScheduler)
|
||||
{
|
||||
if ( ! isCalledFromScheduler )
|
||||
|
@ -90,7 +91,7 @@ public class StatsController {
|
|||
/**
|
||||
* This endpoint returns the number of legacy payloads, which were aggregated by methods other thant the PDF Aggregation Service.
|
||||
* */
|
||||
@GetMapping("getNumberOfLegacyPayloads")
|
||||
@GetMapping(value = "getNumberOfLegacyPayloads", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
public ResponseEntity<?> getNumberOfLegacyPayloads(boolean isCalledFromScheduler)
|
||||
{
|
||||
if ( ! isCalledFromScheduler )
|
||||
|
@ -104,7 +105,7 @@ public class StatsController {
|
|||
/**
|
||||
* This endpoint returns the number of payloads related to the given datasourceID.
|
||||
* */
|
||||
@GetMapping("getNumberOfPayloadsForDatasource")
|
||||
@GetMapping(value = "getNumberOfPayloadsForDatasource", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
public ResponseEntity<?> getNumberOfPayloadsForDatasource(@RequestParam String datasourceId) {
|
||||
logger.info("Received a \"getNumberOfPayloadsForDatasource\" request.");
|
||||
final String getNumOfPayloadsForDatasourceQuery =
|
||||
|
@ -148,7 +149,7 @@ public class StatsController {
|
|||
/**
|
||||
* This endpoint returns the total number of distinct full-text files existing in the database.
|
||||
* */
|
||||
@GetMapping("getNumberOfAllDistinctFullTexts")
|
||||
@GetMapping(value = "getNumberOfAllDistinctFullTexts", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
public ResponseEntity<?> getNumberOfAllDistinctFullTexts() {
|
||||
logger.info("Received a \"getNumberOfAllDistinctFullTexts\" request.");
|
||||
final String getPayloadsNumberQuery = "select count(distinct `hash`) from " + ImpalaConnector.databaseName + ".payload";
|
||||
|
@ -159,7 +160,7 @@ public class StatsController {
|
|||
/**
|
||||
* This endpoint returns the number of records inspected by the PDF-Aggregation-Service, through crawling.
|
||||
* */
|
||||
@GetMapping("getNumberOfRecordsInspectedByServiceThroughCrawling")
|
||||
@GetMapping(value = "getNumberOfRecordsInspectedByServiceThroughCrawling", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
public ResponseEntity<?> getNumberOfRecordsInspectedByServiceThroughCrawling(boolean isCalledFromScheduler)
|
||||
{
|
||||
if ( ! isCalledFromScheduler )
|
||||
|
|
|
@ -37,7 +37,7 @@ public class StatsServiceImpl implements StatsService {
|
|||
if ( result != null ) {
|
||||
int numOfPayloads = (int) result;
|
||||
logger.info("The number of " + message + " in the database \"" + ImpalaConnector.databaseName + "\" is " + numOfPayloads);
|
||||
return new ResponseEntity<>(numOfPayloads, HttpStatus.OK);
|
||||
return ResponseEntity.ok(Integer.toString(numOfPayloads));
|
||||
} else
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("The number of " + message + " could not be retrieved from the database \"" + ImpalaConnector.databaseName + "\" using the getNumberQuery: " + getNumberQuery);
|
||||
} catch (EmptyResultDataAccessException erdae) {
|
||||
|
@ -76,7 +76,7 @@ public class StatsServiceImpl implements StatsService {
|
|||
if ( result != null ) {
|
||||
int numOfInspectedRecords = (int) result;
|
||||
logger.info("Number of crawling-inspected records from the database \"" + ImpalaConnector.databaseName + "\" is " + numOfInspectedRecords);
|
||||
return new ResponseEntity<>(numOfInspectedRecords, HttpStatus.OK);
|
||||
return ResponseEntity.ok(Integer.toString(numOfInspectedRecords));
|
||||
} else
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("The inspected records' number could not be retrieved from the database \"" + ImpalaConnector.databaseName + "\" using the getInspectedRecordsNumberQuery: " + getInspectedRecordsNumberQuery);
|
||||
} catch (EmptyResultDataAccessException erdae) {
|
||||
|
|
Loading…
Reference in New Issue