1. Add swagger explanation for broker/validator paramaters
2. Change subscribe/unsubcribe methods of broker from GET to POST
This commit is contained in:
parent
a08eee988f
commit
f62403a248
|
@ -19,7 +19,7 @@ import java.util.Map;
|
||||||
public interface BrokerApi {
|
public interface BrokerApi {
|
||||||
|
|
||||||
@RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
DatasourcesBroker getDatasourcesOfUser(@RequestBody String params) throws BrokerException, JSONException;
|
DatasourcesBroker getDatasourcesOfUser(String user,String includeShared,String includeByOthers) throws BrokerException, JSONException;
|
||||||
|
|
||||||
@RequestMapping(value = "/getTopicsForDatasource/{datasourceName}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/getTopicsForDatasource/{datasourceName}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
List<BrowseEntry> getTopicsForDatasource(String datasourceName) throws BrokerException;
|
List<BrowseEntry> getTopicsForDatasource(String datasourceName) throws BrokerException;
|
||||||
|
@ -36,13 +36,15 @@ public interface BrokerApi {
|
||||||
|
|
||||||
@RequestMapping(value = "/getSimpleSubscriptionsOfUser/{userEmail}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/getSimpleSubscriptionsOfUser/{userEmail}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(String userEmail) throws BrokerException;
|
Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(@PathVariable("userEmail") String userEmail) throws BrokerException;
|
||||||
|
|
||||||
@RequestMapping(value = "/subscribe" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/subscribe" , method = RequestMethod.POST,consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||||
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
Subscription subscribe(@RequestBody OpenaireSubscription obj) throws BrokerException;
|
Subscription subscribe(@RequestBody OpenaireSubscription obj) throws BrokerException;
|
||||||
|
|
||||||
@RequestMapping(value = "/unsubscribe/{subscriptionId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/unsubscribe/{subscriptionId}" , method = RequestMethod.POST,consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||||
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
void unsubscribe(String subscriptionId) throws BrokerException;
|
void unsubscribe(String subscriptionId) throws BrokerException;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import eu.dnetlib.repo.manager.shared.BrokerException;
|
||||||
import eu.dnetlib.repo.manager.shared.Term;
|
import eu.dnetlib.repo.manager.shared.Term;
|
||||||
import eu.dnetlib.repo.manager.shared.Tuple;
|
import eu.dnetlib.repo.manager.shared.Tuple;
|
||||||
import eu.dnetlib.repo.manager.shared.broker.*;
|
import eu.dnetlib.repo.manager.shared.broker.*;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -21,6 +22,7 @@ import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.LinkedMultiValueMap;
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.client.RestClientException;
|
import org.springframework.web.client.RestClientException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.util.UriComponents;
|
import org.springframework.web.util.UriComponents;
|
||||||
|
@ -83,24 +85,22 @@ public class BrokerApiImpl implements BrokerApi {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatasourcesBroker getDatasourcesOfUser(String params) throws JSONException {
|
public DatasourcesBroker getDatasourcesOfUser(@RequestParam("user") @ApiParam(value = "User email", required = true) String user,
|
||||||
JSONObject json_params = new JSONObject(params);
|
@RequestParam("includeShared")
|
||||||
|
@ApiParam(value = "Include shared datasources", required = true) String includeShared,
|
||||||
|
@RequestParam("includeByOthers") @ApiParam(value = "Include datasources of other", required = true) String includeByOthers) throws JSONException {
|
||||||
|
|
||||||
DatasourcesBroker ret = new DatasourcesBroker();
|
DatasourcesBroker ret = new DatasourcesBroker();
|
||||||
|
|
||||||
String userEmail = json_params.getString("userEmail");
|
|
||||||
boolean includeShared = Boolean.parseBoolean( json_params.getString("includeShared") );
|
|
||||||
boolean includeByOthers = Boolean.parseBoolean( json_params.getString("includeByOthers") );
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ret.setDatasourcesOfUser(getDatasourcesOfUserType(getRepositoriesOfUser(userEmail)));
|
ret.setDatasourcesOfUser(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
|
||||||
if (includeShared) {
|
if (Boolean.parseBoolean(includeShared)) {
|
||||||
//TODO whatever nikonas was saying
|
//TODO whatever nikonas was saying
|
||||||
List<String> sharedDatasourceIds = new ArrayList<String>();
|
List<String> sharedDatasourceIds = new ArrayList<String>();
|
||||||
ret.setSharedDatasources(getDatasourcesOfUserType(getRepositoriesByIds(sharedDatasourceIds)));
|
ret.setSharedDatasources(getDatasourcesOfUserType(getRepositoriesByIds(sharedDatasourceIds)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeByOthers) {
|
if (Boolean.parseBoolean(includeByOthers)) {
|
||||||
ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(userEmail)));
|
ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
|
||||||
}
|
}
|
||||||
} catch (BrokerException e) {
|
} catch (BrokerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -251,18 +251,17 @@ public class BrokerApiImpl implements BrokerApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(@PathVariable("userEmail") String userEmail) throws BrokerException {
|
public Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser( String userEmail)
|
||||||
|
throws BrokerException {
|
||||||
|
|
||||||
final String service = "/subscriptions";
|
final String service = "/subscriptions";
|
||||||
|
|
||||||
//build the uri params
|
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
||||||
.queryParam("email", userEmail);
|
.queryParam("email", userEmail);
|
||||||
|
|
||||||
//create new template engine
|
LOGGER.debug(builder.build().encode().toUri());
|
||||||
ResponseEntity<Map<String, List<SimpleSubscriptionDesc>>> resp;
|
ResponseEntity<Map<String, List<SimpleSubscriptionDesc>>> resp;
|
||||||
try {
|
try {
|
||||||
//communicate with endpoint
|
|
||||||
resp = restTemplate.exchange(
|
resp = restTemplate.exchange(
|
||||||
builder.build().encode().toUri(),
|
builder.build().encode().toUri(),
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
|
|
|
@ -38,9 +38,10 @@ public class MonitorApiImpl implements MonitorApi {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JobsOfUser getJobsOfUser(@RequestParam("user") @ApiParam(value = "User email", required = true) String user,
|
public JobsOfUser getJobsOfUser(@RequestParam("user") @ApiParam(value = "User email", required = true) String user,
|
||||||
@RequestParam(value = "jobType", required = false) @ApiParam(value = "Equals to filter job type on validation history page") String jobType,
|
@RequestParam(value = "jobType", required = false)
|
||||||
|
@ApiParam(value = "Equals to filter job type on validation history page") String jobType,
|
||||||
@RequestParam("offset") @ApiParam(value = "Page number", required = true) String offset,
|
@RequestParam("offset") @ApiParam(value = "Page number", required = true) String offset,
|
||||||
@RequestParam(value = "limit", required = false, defaultValue = "10") @ApiParam(value = "Null value") String limit,
|
@RequestParam(value = "limit", required = false,defaultValue = "10") @ApiParam(value = "Null value") String limit,
|
||||||
@RequestParam(value = "dateFrom", required = false) @ApiParam(value = "Null value") String dateFrom,
|
@RequestParam(value = "dateFrom", required = false) @ApiParam(value = "Null value") String dateFrom,
|
||||||
@RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo,
|
@RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo,
|
||||||
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = true) String validationStatus,
|
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = true) String validationStatus,
|
||||||
|
|
|
@ -45,8 +45,13 @@ public interface ValidatorApi {
|
||||||
|
|
||||||
@RequestMapping(value = "/getStoredJobsNew" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/getStoredJobsNew" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
List<StoredJob> getStoredJobsNew(String user, String jobType, Integer offset, Integer limit, String dateFrom,
|
List<StoredJob> getStoredJobsNew(String user,
|
||||||
String dateTo, String validationStatus) throws ValidatorServiceException;
|
String jobType,
|
||||||
|
String offset,
|
||||||
|
String limit,
|
||||||
|
String dateFrom,
|
||||||
|
String dateTo,
|
||||||
|
String validationStatus) throws ValidatorServiceException;
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "/getStoredJobsTotalNumberNew" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/getStoredJobsTotalNumberNew" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
|
|
@ -168,13 +168,15 @@ public class ValidatorApiImpl implements ValidatorApi{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<StoredJob> getStoredJobsNew(@RequestParam("user") @ApiParam(value = "User email", required = true) String user,
|
public List<StoredJob> getStoredJobsNew(@RequestParam("user") @ApiParam(value = "User email", required = true) String user,
|
||||||
@RequestParam("jobType") @ApiParam(value = "Equals to filter job type on validation history page", required = true) String jobType,
|
@RequestParam(value = "jobType", required = false)
|
||||||
@RequestParam("offset") @ApiParam(value = "Page number", required = true) Integer offset,
|
@ApiParam(value = "Equals to filter job type on validation history page") String jobType,
|
||||||
@RequestParam(value = "limit", required = false, defaultValue = "10") @ApiParam(value = "Null value") Integer limit,
|
@RequestParam("offset") @ApiParam(value = "Page number", required = true) String offset,
|
||||||
@RequestParam(value = "dateFrom", required = false, defaultValue = "2018-02-08") @ApiParam(value = "Null value") String dateFrom,
|
@RequestParam(value = "limit", required = false,defaultValue = "10") @ApiParam(value = "Null value") String limit,
|
||||||
@RequestParam(value = "dateTo", required = false, defaultValue = "2018-02-08") @ApiParam(value = "Null value") String dateTo,
|
@RequestParam(value = "dateFrom", required = false) @ApiParam(value = "Null value") String dateFrom,
|
||||||
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = true) String validationStatus) throws ValidatorServiceException {
|
@RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo,
|
||||||
return getValidationService().getStoredJobsNew(user, jobType, offset, limit, dateFrom, dateTo, validationStatus);
|
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = true) String validationStatus
|
||||||
|
) throws ValidatorServiceException {
|
||||||
|
return getValidationService().getStoredJobsNew(user, jobType, Integer.parseInt(offset), Integer.parseInt(limit), dateFrom, dateTo, validationStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue