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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
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 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.
|
* 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)
|
public ResponseEntity<?> getNumberOfAllPayloads(boolean isCalledFromScheduler)
|
||||||
{
|
{
|
||||||
if ( ! 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.
|
* 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)
|
public ResponseEntity<?> getNumberOfPayloadsAggregatedByServiceThroughCrawling(boolean isCalledFromScheduler)
|
||||||
{
|
{
|
||||||
if ( ! 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..
|
* 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)
|
public ResponseEntity<?> getNumberOfPayloadsAggregatedByServiceThroughBulkImport(boolean isCalledFromScheduler)
|
||||||
{
|
{
|
||||||
if ( ! 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.
|
* 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)
|
public ResponseEntity<?> getNumberOfPayloadsAggregatedByService(boolean isCalledFromScheduler)
|
||||||
{
|
{
|
||||||
if ( ! 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.
|
* 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)
|
public ResponseEntity<?> getNumberOfLegacyPayloads(boolean isCalledFromScheduler)
|
||||||
{
|
{
|
||||||
if ( ! isCalledFromScheduler )
|
if ( ! isCalledFromScheduler )
|
||||||
|
@ -104,7 +105,7 @@ public class StatsController {
|
||||||
/**
|
/**
|
||||||
* This endpoint returns the number of payloads related to the given datasourceID.
|
* 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) {
|
public ResponseEntity<?> getNumberOfPayloadsForDatasource(@RequestParam String datasourceId) {
|
||||||
logger.info("Received a \"getNumberOfPayloadsForDatasource\" request.");
|
logger.info("Received a \"getNumberOfPayloadsForDatasource\" request.");
|
||||||
final String getNumOfPayloadsForDatasourceQuery =
|
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.
|
* 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() {
|
public ResponseEntity<?> getNumberOfAllDistinctFullTexts() {
|
||||||
logger.info("Received a \"getNumberOfAllDistinctFullTexts\" request.");
|
logger.info("Received a \"getNumberOfAllDistinctFullTexts\" request.");
|
||||||
final String getPayloadsNumberQuery = "select count(distinct `hash`) from " + ImpalaConnector.databaseName + ".payload";
|
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.
|
* 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)
|
public ResponseEntity<?> getNumberOfRecordsInspectedByServiceThroughCrawling(boolean isCalledFromScheduler)
|
||||||
{
|
{
|
||||||
if ( ! isCalledFromScheduler )
|
if ( ! isCalledFromScheduler )
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class StatsServiceImpl implements StatsService {
|
||||||
if ( result != null ) {
|
if ( result != null ) {
|
||||||
int numOfPayloads = (int) result;
|
int numOfPayloads = (int) result;
|
||||||
logger.info("The number of " + message + " in the database \"" + ImpalaConnector.databaseName + "\" is " + numOfPayloads);
|
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
|
} 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);
|
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) {
|
} catch (EmptyResultDataAccessException erdae) {
|
||||||
|
@ -76,7 +76,7 @@ public class StatsServiceImpl implements StatsService {
|
||||||
if ( result != null ) {
|
if ( result != null ) {
|
||||||
int numOfInspectedRecords = (int) result;
|
int numOfInspectedRecords = (int) result;
|
||||||
logger.info("Number of crawling-inspected records from the database \"" + ImpalaConnector.databaseName + "\" is " + numOfInspectedRecords);
|
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
|
} 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);
|
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) {
|
} catch (EmptyResultDataAccessException erdae) {
|
||||||
|
|
Loading…
Reference in New Issue