@ -16,10 +16,11 @@ import org.apache.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty ;
import org.springframework.web.bind.annotation.CrossOrigin ;
import org.springframework.web.bind.annotation.DeleteMapping ;
import org.springframework.web.bind.annotation.GetMapping ;
import org.springframework.web.bind.annotation.PathVariable ;
import org.springframework.web.bind.annotation.PostMapping ;
import org.springframework.web.bind.annotation.RequestBody ;
import org.springframework.web.bind.annotation.RequestMapping ;
import org.springframework.web.bind.annotation.RequestMethod ;
import org.springframework.web.bind.annotation.RequestParam ;
import org.springframework.web.bind.annotation.RestController ;
@ -28,7 +29,6 @@ import eu.dnetlib.enabling.datasources.common.DsmForbiddenException;
import eu.dnetlib.enabling.datasources.common.DsmNotFoundException ;
import eu.dnetlib.openaire.common.AbstractExporterController ;
import eu.dnetlib.openaire.common.OperationManager ;
import eu.dnetlib.openaire.dsm.dao.ResponseUtils ;
import eu.dnetlib.openaire.dsm.domain.AggregationHistoryResponse ;
import eu.dnetlib.openaire.dsm.domain.ApiDetails ;
import eu.dnetlib.openaire.dsm.domain.ApiDetailsResponse ;
@ -41,8 +41,6 @@ import eu.dnetlib.openaire.dsm.domain.RegisteredDatasourceInfo;
import eu.dnetlib.openaire.dsm.domain.RequestFilter ;
import eu.dnetlib.openaire.dsm.domain.RequestSort ;
import eu.dnetlib.openaire.dsm.domain.RequestSortOrder ;
import eu.dnetlib.openaire.dsm.domain.Response ;
import eu.dnetlib.openaire.dsm.domain.SimpleDatasourceInfo ;
import eu.dnetlib.openaire.dsm.domain.SimpleResponse ;
import eu.dnetlib.openaire.vocabularies.Country ;
import io.swagger.v3.oas.annotations.Operation ;
@ -61,9 +59,9 @@ public class DsmApiController extends AbstractExporterController {
@Autowired
private DsmCore dsmCore ;
@ Reques tMapping( value = "/ds/countries" , produces = {
@ Ge tMapping( value = "/ds/countries" , produces = {
"application/json"
} , method = RequestMethod . GET )
} )
@Operation ( summary = "list the datasource countries" , description = "list the datasource countries" , tags = {
DS , R
} )
@ -75,9 +73,9 @@ public class DsmApiController extends AbstractExporterController {
return dsmCore . listCountries ( ) ;
}
@ Reque stMapping( value = "/ds/searchdetails/{page}/{size}" , produces = {
@ Po stMapping( value = "/ds/searchdetails/{page}/{size}" , produces = {
"application/json"
} , method = RequestMethod . POST )
} )
@Operation ( summary = "search datasources" , description = "Returns list of Datasource details." , tags = {
DS , R
} )
@ -96,9 +94,9 @@ public class DsmApiController extends AbstractExporterController {
return prepareResponse ( page , size , stop , rsp ) ;
}
@ Reques tMapping( value = "/ds/aggregationhistory/{dsId}" , produces = {
@ Ge tMapping( value = "/ds/aggregationhistory/{dsId}" , produces = {
"application/json"
} , method = RequestMethod . GET )
} )
@Operation ( summary = "search datasources" , description = "Returns list of Datasource details." , tags = {
DS , R
} )
@ -112,9 +110,9 @@ public class DsmApiController extends AbstractExporterController {
return prepareResponse ( 0 , rsp . getAggregationInfo ( ) . size ( ) , stop , rsp ) ;
}
@ Reque stMapping( value = "/ds/searchsnippet/{page}/{size}" , produces = {
@ Po stMapping( value = "/ds/searchsnippet/{page}/{size}" , produces = {
"application/json"
} , method = RequestMethod . POST )
} )
@Operation ( summary = "search datasources" , description = "Returns list of Datasource basic info." , tags = {
DS , R
} )
@ -133,9 +131,9 @@ public class DsmApiController extends AbstractExporterController {
return prepareResponse ( page , size , stop , rsp ) ;
}
@ Reque stMapping( value = "/ds/searchregistered/{page}/{size}" , produces = {
@ Po stMapping( value = "/ds/searchregistered/{page}/{size}" , produces = {
"application/json"
} , method = RequestMethod . POST )
} )
@Operation ( summary = "search among registered datasources" , description = "Returns list of Datasource basic info." , tags = {
DS ,
R
@ -155,9 +153,9 @@ public class DsmApiController extends AbstractExporterController {
return prepareResponse ( page , size , stop , rsp ) ;
}
@ Reques tMapping( value = "/ds/recentregistered/{size}" , produces = {
@ Ge tMapping( value = "/ds/recentregistered/{size}" , produces = {
"application/json"
} , method = RequestMethod . GET )
} )
@Operation ( summary = "return the latest datasources that were registered through Provide" , description = "Returns list of Datasource basic info." , tags = {
DS ,
R
@ -172,9 +170,9 @@ public class DsmApiController extends AbstractExporterController {
return prepareResponse ( 1 , size , stop , rsp ) ;
}
@ Reques tMapping( value = "/ds/countregistered" , produces = {
@ Ge tMapping( value = "/ds/countregistered" , produces = {
"application/json"
} , method = RequestMethod . GET )
} )
@Operation ( summary = "return the number of datasources registered after the given date" , description = "Returns a number." , tags = {
DS ,
R
@ -188,9 +186,9 @@ public class DsmApiController extends AbstractExporterController {
return dsmCore . countRegisteredAfter ( fromDate , typologyFilter ) ;
}
@ Reques tMapping( value = "/ds/api/{dsId}" , produces = {
@ Ge tMapping( value = "/ds/api/{dsId}" , produces = {
"application/json"
} , method = RequestMethod . GET )
} )
@Operation ( summary = "get the list of API for a given datasource" , description = "Returns the list of API for a given datasource." , tags = {
API ,
R
@ -207,9 +205,9 @@ public class DsmApiController extends AbstractExporterController {
return prepareResponse ( 0 , rsp . getApi ( ) . size ( ) , stop , rsp ) ;
}
@ Reque stMapping( value = "/api/baseurl/{page}/{size}" , produces = {
@ Po stMapping( value = "/api/baseurl/{page}/{size}" , produces = {
"application/json"
} , method = RequestMethod . POST )
} )
@Operation ( summary = "search for the list of base URLs of Datasource APIs managed by a user" , description = "Returns the list of base URLs of Datasource APIs managed by a user" , tags = {
DS , API , R
} )
@ -225,7 +223,7 @@ public class DsmApiController extends AbstractExporterController {
return dsmCore . findBaseURLs ( requestFilter , page , size ) ;
}
@ Request Mapping( value = "/ds/api/{apiId}" , method = RequestMethod . DELETE )
@ Delete Mapping( value = "/ds/api/{apiId}" )
@Operation ( summary = "delete an API" , description = "delete an API, if removable" , tags = {
API , W
} )
@ -239,7 +237,7 @@ public class DsmApiController extends AbstractExporterController {
dsmCore . deleteApi ( apiId ) ;
}
@ Reque stMapping( value = "/ds/manage" , method = RequestMethod . POST )
@ Po stMapping( value = "/ds/manage" )
@Operation ( summary = "set the managed status for a given datasource" , description = "set the managed status for a given datasource" , tags = {
DS , W
} )
@ -254,7 +252,7 @@ public class DsmApiController extends AbstractExporterController {
dsmCore . setManaged ( id , managed ) ;
}
@ Reques tMapping( value = "/ds/managed/{id}" , method = RequestMethod . GET )
@ Ge tMapping( value = "/ds/managed/{id}" )
@Operation ( summary = "get the datasource managed status" , description = "get the datasource managed status" , tags = {
DS , R
} )
@ -266,7 +264,7 @@ public class DsmApiController extends AbstractExporterController {
return dsmCore . isManaged ( id ) ;
}
@ Reque stMapping( value = "/ds/add" , method = RequestMethod . POST )
@ Po stMapping( value = "/ds/add" )
@Operation ( summary = "add a new Datasource" , description = "add a new Datasource" , tags = {
DS , W
} )
@ -283,7 +281,7 @@ public class DsmApiController extends AbstractExporterController {
dsmCore . save ( datasource ) ;
}
@ Reque stMapping( value = "/ds/addWithApis" , method = RequestMethod . POST )
@ Po stMapping( value = "/ds/addWithApis" )
@Operation ( summary = "add a new Datasource and its apis" , description = "add a new Datasource and its apis" , tags = {
DS , W
} )
@ -300,7 +298,7 @@ public class DsmApiController extends AbstractExporterController {
dsmCore . save ( d ) ;
}
@ Reque stMapping( value = "/ds/update" , method = RequestMethod . POST )
@ Po stMapping( value = "/ds/update" )
@Operation ( summary = "update Datasource details" , description = "update Datasource details" , tags = {
DS , W
} )
@ -314,7 +312,7 @@ public class DsmApiController extends AbstractExporterController {
dsmCore . updateDatasource ( ds ) ;
}
@ Reque stMapping( value = "/ds/api/baseurl" , method = RequestMethod . POST )
@ Po stMapping( value = "/ds/api/baseurl" )
@Operation ( summary = "update the base URL of a datasource interface" , description = "update the base URL of a datasource interface" , tags = {
API , W
} )
@ -330,7 +328,7 @@ public class DsmApiController extends AbstractExporterController {
dsmCore . updateApiBaseurl ( dsId , apiId , baseUrl ) ;
}
@ Reque stMapping( value = "/ds/api/compliance" , method = RequestMethod . POST )
@ Po stMapping( value = "/ds/api/compliance" )
@Operation ( summary = "update the compatibility of a datasource interface" , description = "update the compatibility of a datasource interface" , tags = {
API , W
} )
@ -347,7 +345,7 @@ public class DsmApiController extends AbstractExporterController {
dsmCore . updateApiCompatibility ( dsId , apiId , compliance , override ) ;
}
@ Reque stMapping( value = "/ds/api/oaiset" , method = RequestMethod . POST )
@ Po stMapping( value = "/ds/api/oaiset" )
@Operation ( summary = "update the OAI set of a datasource interface" , description = "update the OAI set of a datasource interface" , tags = {
API , W
} )
@ -363,7 +361,7 @@ public class DsmApiController extends AbstractExporterController {
dsmCore . updateApiOaiSet ( dsId , apiId , oaiSet ) ;
}
@ Reque stMapping( value = "/ds/api/add" , method = RequestMethod . POST )
@ Po stMapping( value = "/ds/api/add" )
@Operation ( summary = "adds a new Interface to one Datasource" , description = "adds an Interface to one Datasource" , tags = {
API , W
} )
@ -381,7 +379,7 @@ public class DsmApiController extends AbstractExporterController {
@Autowired
private OperationManager operationManager ;
@ Reques tMapping( value = "/dsm/ops" , method = RequestMethod . GET )
@ Ge tMapping( value = "/dsm/ops" )
@Operation ( summary = "get the number of pending operations" , description = "get the number of pending operations" , tags = {
R , M
} )
@ -393,7 +391,7 @@ public class DsmApiController extends AbstractExporterController {
return operationManager . getOpSize ( ) ;
}
@ Reque stMapping( value = "/dsm/killops" , method = RequestMethod . POST )
@ Po stMapping( value = "/dsm/killops" )
@Operation ( summary = "interrupts the pending operations" , description = "return the number of interrupted operations" , tags = {
W , M
} )
@ -405,7 +403,7 @@ public class DsmApiController extends AbstractExporterController {
return operationManager . dropAll ( ) ;
}
@ Reque stMapping( value = "/dsm/dropcache" , method = RequestMethod . POST )
@ Po stMapping( value = "/dsm/dropcache" )
@Operation ( summary = "drop the caches" , description = "drop the internal caches" , tags = {
W , M
} )
@ -417,68 +415,4 @@ public class DsmApiController extends AbstractExporterController {
dsmCore . dropCaches ( ) ;
}
// HELPERS
private < T extends Response > T prepareResponse ( final int page , final int size , final StopWatch stopWatch , final T rsp ) {
rsp . getHeader ( )
. setTime ( stopWatch . getTime ( ) )
. setPage ( page )
. setSize ( size ) ;
return rsp ;
}
// ------------------------------
@RequestMapping ( value = "/ds/recentregistered/v2/{size}" , produces = {
"application/json"
} , method = RequestMethod . GET )
@Operation ( summary = "return the latest datasources that were registered through Provide (v2)" , description = "Returns list of Datasource basic info." , tags = {
DS ,
R
} )
@ApiResponses ( value = {
@ApiResponse ( responseCode = "200" , description = "OK" ) ,
@ApiResponse ( responseCode = "500" , description = "unexpected error" )
} )
public SimpleResponse < SimpleDatasourceInfo > recentRegisteredV2 ( @PathVariable final int size ) throws Throwable {
final StopWatch stop = StopWatch . createStarted ( ) ;
final SimpleResponse < SimpleDatasourceInfo > rsp = dsmCore . searchRecentRegisteredV2 ( size ) ;
return prepareResponse ( 1 , size , stop , rsp ) ;
}
@RequestMapping ( value = "/ds/countfirstcollect" , produces = {
"application/json"
} , method = RequestMethod . GET )
@Operation ( summary = "return the number of datasources registered after the given date" , description = "Returns a number." , tags = {
DS ,
R
} )
@ApiResponses ( value = {
@ApiResponse ( responseCode = "200" , description = "OK" ) ,
@ApiResponse ( responseCode = "500" , description = "unexpected error" )
} )
public Long countFirstCollectAfter ( @RequestParam final String fromDate ,
@RequestParam ( required = false ) final String typologyFilter ) throws Throwable {
return dsmCore . countFirstCollect ( fromDate , typologyFilter ) ;
}
@RequestMapping ( value = "/ds/firstCollected" , produces = {
"application/json"
} , method = RequestMethod . GET )
@Operation ( summary = "return the datasources that were collected for the first time after the specified date" , description = "Returns list of Datasource basic info." , tags = {
DS ,
R
} )
@ApiResponses ( value = {
@ApiResponse ( responseCode = "200" , description = "OK" ) ,
@ApiResponse ( responseCode = "500" , description = "unexpected error" )
} )
public SimpleResponse < SimpleDatasourceInfo > firstCollectedAfter ( @RequestParam final String fromDate ,
@RequestParam ( required = false ) final String typologyFilter ) throws Throwable {
final StopWatch stop = StopWatch . createStarted ( ) ;
final List < SimpleDatasourceInfo > list = dsmCore . getFirstCollectedAfter ( fromDate , typologyFilter ) ;
final SimpleResponse < SimpleDatasourceInfo > rsp = ResponseUtils . simpleResponse ( list ) ;
return prepareResponse ( 1 , list . size ( ) , stop , rsp ) ;
}
}