1. Broker api bug fixes on urls

2. Piwik changes on methods.
3. Validator url changes
This commit is contained in:
Panagiotis Kanakakis 2018-02-22 10:55:56 +00:00
parent 7f00c2f321
commit a396e42e06
6 changed files with 27 additions and 29 deletions

View File

@ -40,7 +40,8 @@ public interface BrokerApi {
@ResponseBody
EventsPage showEvents(String datasourceName,
String topic,
String page) throws BrokerException, JSONException;
String page,
String size) throws BrokerException, JSONException;
@RequestMapping(value = "/getSimpleSubscriptionsOfUser/{userEmail}" , method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)

View File

@ -86,16 +86,18 @@ public class BrokerApiImpl implements BrokerApi {
@Override
public DatasourcesBroker getDatasourcesOfUser(@RequestParam("user") @ApiParam(value = "User email", required = true) String user,
public DatasourcesBroker getDatasourcesOfUser(@RequestParam("user")
@ApiParam(value = "User email", required = true) String user,
@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 {
@ApiParam(value = "Include shared datasources", required = true , defaultValue = "false") String includeShared,
@RequestParam("includeByOthers")
@ApiParam(value = "Include datasources of other", required = true,defaultValue = "false") String includeByOthers) throws JSONException {
DatasourcesBroker ret = new DatasourcesBroker();
try {
ret.setDatasourcesOfUser(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
//TODO fix bug when values are true
if (Boolean.parseBoolean(includeShared)) {
//TODO whatever nikonas was saying
List<String> sharedDatasourceIds = new ArrayList<String>();
ret.setSharedDatasources(getDatasourcesOfUserType(getRepositoriesByIds(sharedDatasourceIds)));
}
@ -214,29 +216,22 @@ public class BrokerApiImpl implements BrokerApi {
}
@Override
public EventsPage showEvents(@PathVariable("datasourceName") String datasourceName,
@PathVariable("topic") String topic,
@PathVariable("page") String page) throws BrokerException, JSONException {
public EventsPage showEvents(@RequestParam("datasourceName") String datasourceName,
@RequestParam("topic") String topic,
@RequestParam("page") String page,
@RequestParam("size") String size) throws BrokerException, JSONException {
/*JSONObject json_params = new JSONObject(params);
final String service = "/events";
String datasourceName = json_params.getString("datasourceName");
String topic = json_params.getString("topic");
String page = json_params.getString("page");*/
final String service = "/showEvents";
//build the uri params
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service)
.queryParam("ds", datasourceName)
.queryParam("topic", topic)
.queryParam("page", page);
.path("/{page}/{size}/");
ResponseEntity<EventsPage> resp;
try {
//communicate with endpoint
resp = restTemplate.exchange(
builder.build().encode().toUri(),
builder.build().expand(page, size).encode().toUri(),
HttpMethod.GET,
null,
new ParameterizedTypeReference<EventsPage>() {

View File

@ -19,7 +19,7 @@ public interface PiWikApi {
PiwikInfo getPiwikSiteForRepo(String repositoryId);
@RequestMapping(value = "/savePiwikInfo" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
PiwikInfo savePiwikInfo(@RequestBody PiwikInfo piwikInfo);
PiwikInfo savePiwikInfo( PiwikInfo piwikInfo);
@RequestMapping(value = "/getPiwikSitesForRepos" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
List<PiwikInfo> getPiwikSitesForRepos();

View File

@ -9,6 +9,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.PostConstruct;
import javax.sql.DataSource;
@ -52,7 +53,7 @@ public class PiWikApiImpl implements PiWikApi{
}
@Override
public PiwikInfo savePiwikInfo(PiwikInfo piwikInfo) {
public PiwikInfo savePiwikInfo(@RequestBody PiwikInfo piwikInfo) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.update(INSERT_PIWIK_INFO, new Object[]{piwikInfo.getRepositoryId(), piwikInfo.getSiteId(), piwikInfo.getRequestorName(),
piwikInfo.getRequestorEmail(), piwikInfo.isValidated(), piwikInfo.getRepositoryName(), piwikInfo.getCountry(), piwikInfo.getAuthenticationToken()},

View File

@ -21,21 +21,21 @@ public interface ValidatorApi {
@RequestMapping(value = "/submitJobForValidation",method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE )
@ResponseBody
void submitJobForValidation(@RequestBody JobForValidation jobForValidation);
void submitJobForValidation(JobForValidation jobForValidation);
@RequestMapping(value = "/reSubmitJobForValidation/",method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE )
@RequestMapping(value = "/reSubmitJobForValidation/{jobId}",method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE )
@ResponseBody
void reSubmitJobForValidation(@RequestBody String jobId) throws JSONException;
void reSubmitJobForValidation(String jobId) throws JSONException;
@RequestMapping(value = "/getRuleSets/{mode}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
List<RuleSet> getRuleSets(String mode);
@RequestMapping(value = "/getSetsOfRepository/{url}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/getSetsOfRepository" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
List<String> getSetsOfRepository(String url);
@RequestMapping(value = "/identifyRepository/{url}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/identifyRepository" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
boolean identifyRepo(String url);
@ -58,7 +58,7 @@ public interface ValidatorApi {
@ResponseBody
int getStoredJobsTotalNumberNew(String user, String jobType, String validationStatus) throws ValidatorServiceException;
@RequestMapping(value = "/getInterfaceInformation/{baseUrl}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/getInterfaceInformation/" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException;
}

View File

@ -19,6 +19,7 @@ import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import javax.annotation.PostConstruct;
@ -81,7 +82,7 @@ public class ValidatorApiImpl implements ValidatorApi{
}
@Override
public void submitJobForValidation(JobForValidation jobForValidation) {
public void submitJobForValidation(@RequestBody JobForValidation jobForValidation) {
LOGGER.debug("Submit job for validation with id : " + jobForValidation.getDatasourceId());
try {
this.getValidationService().submitValidationJob(jobForValidation);
@ -91,7 +92,7 @@ public class ValidatorApiImpl implements ValidatorApi{
}
@Override
public void reSubmitJobForValidation(String jobId) throws JSONException {
public void reSubmitJobForValidation(@PathVariable("jobId") String jobId) throws JSONException {
LOGGER.debug("Resubmit validation job with id : " + jobId);
StoredJob job = monitorApi.getJobSummary(jobId,"all");
Set<Integer> contentRules = new HashSet<Integer>();