From a396e42e067f7825d72de49bf1b7f9cb0b6f8c2e Mon Sep 17 00:00:00 2001 From: "panagiotis.kanakakis" Date: Thu, 22 Feb 2018 10:55:56 +0000 Subject: [PATCH] 1. Broker api bug fixes on urls 2. Piwik changes on methods. 3. Validator url changes --- .../service/controllers/BrokerApi.java | 3 +- .../service/controllers/BrokerApiImpl.java | 31 ++++++++----------- .../manager/service/controllers/PiWikApi.java | 2 +- .../service/controllers/PiWikApiImpl.java | 3 +- .../service/controllers/ValidatorApi.java | 12 +++---- .../service/controllers/ValidatorApiImpl.java | 5 +-- 6 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/main/java/eu/dnetlib/repo/manager/service/controllers/BrokerApi.java b/src/main/java/eu/dnetlib/repo/manager/service/controllers/BrokerApi.java index 58d97f0..393412d 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/controllers/BrokerApi.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/controllers/BrokerApi.java @@ -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) diff --git a/src/main/java/eu/dnetlib/repo/manager/service/controllers/BrokerApiImpl.java b/src/main/java/eu/dnetlib/repo/manager/service/controllers/BrokerApiImpl.java index 0250542..b36ae62 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/controllers/BrokerApiImpl.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/controllers/BrokerApiImpl.java @@ -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 sharedDatasourceIds = new ArrayList(); 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 resp; try { - //communicate with endpoint resp = restTemplate.exchange( - builder.build().encode().toUri(), + builder.build().expand(page, size).encode().toUri(), HttpMethod.GET, null, new ParameterizedTypeReference() { diff --git a/src/main/java/eu/dnetlib/repo/manager/service/controllers/PiWikApi.java b/src/main/java/eu/dnetlib/repo/manager/service/controllers/PiWikApi.java index 95fec39..cf8866b 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/controllers/PiWikApi.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/controllers/PiWikApi.java @@ -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 getPiwikSitesForRepos(); diff --git a/src/main/java/eu/dnetlib/repo/manager/service/controllers/PiWikApiImpl.java b/src/main/java/eu/dnetlib/repo/manager/service/controllers/PiWikApiImpl.java index 35840b3..38621d1 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/controllers/PiWikApiImpl.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/controllers/PiWikApiImpl.java @@ -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()}, diff --git a/src/main/java/eu/dnetlib/repo/manager/service/controllers/ValidatorApi.java b/src/main/java/eu/dnetlib/repo/manager/service/controllers/ValidatorApi.java index f70499f..0c5cf90 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/controllers/ValidatorApi.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/controllers/ValidatorApi.java @@ -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 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 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; } diff --git a/src/main/java/eu/dnetlib/repo/manager/service/controllers/ValidatorApiImpl.java b/src/main/java/eu/dnetlib/repo/manager/service/controllers/ValidatorApiImpl.java index 3aebfd9..11ef811 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/controllers/ValidatorApiImpl.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/controllers/ValidatorApiImpl.java @@ -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 contentRules = new HashSet();