Revision 49362
Added by Panagiotis Kanakakis over 6 years ago
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/rest/MonitorApi.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.service.rest; |
|
2 |
|
|
3 |
import eu.dnetlib.domain.functionality.validator.StoredJob; |
|
4 |
import org.springframework.http.MediaType; |
|
5 |
import org.springframework.web.bind.annotation.RequestBody; |
|
6 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
7 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
8 |
import org.springframework.web.bind.annotation.RestController; |
|
9 |
|
|
10 |
import java.util.List; |
|
11 |
|
|
12 |
@RestController |
|
13 |
@RequestMapping(value = "/monitor") |
|
14 |
public interface MonitorApi { |
|
15 |
|
|
16 |
@RequestMapping(value = "/getJobsOfUser" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) |
|
17 |
List<StoredJob> getJobsOfUser(@RequestBody String params); |
|
18 |
|
|
19 |
@RequestMapping(value = "/getJobsOfUser" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) |
|
20 |
int getJobsOfUserPerValidationStatus(@RequestBody String params); |
|
21 |
|
|
22 |
@RequestMapping(value = "/getJobSummary" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) |
|
23 |
StoredJob getJobSummary(@RequestBody String params); |
|
24 |
|
|
25 |
} |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/rest/ValidatorApiImpl.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.service.rest; |
|
2 |
|
|
3 |
import eu.dnetlib.api.functionality.ValidatorServiceException; |
|
4 |
import eu.dnetlib.domain.functionality.validator.StoredJob; |
|
5 |
import eu.dnetlib.repo.manager.service.utils.OaiTools; |
|
6 |
import gr.uoa.di.driver.util.ServiceLocator; |
|
7 |
import eu.dnetlib.domain.functionality.validator.JobForValidation; |
|
8 |
import eu.dnetlib.domain.functionality.validator.RuleSet; |
|
9 |
import eu.dnetlib.repo.manager.service.utils.Constants; |
|
10 |
|
|
11 |
import java.util.*; |
|
12 |
import java.util.concurrent.ConcurrentHashMap; |
|
13 |
import eu.dnetlib.api.functionality.ValidatorService; |
|
14 |
import org.json.JSONObject; |
|
15 |
import org.springframework.beans.factory.annotation.Autowired; |
|
16 |
import org.springframework.stereotype.Component; |
|
17 |
import org.springframework.web.bind.annotation.PathVariable; |
|
18 |
|
|
19 |
import javax.annotation.PostConstruct; |
|
20 |
|
|
21 |
@Component |
|
22 |
public class ValidatorApiImpl implements ValidatorApi{ |
|
23 |
|
|
24 |
@Autowired |
|
25 |
private MonitorApiImpl monitorApi; |
|
26 |
|
|
27 |
private ServiceLocator<ValidatorService> validatorServiceLocator; |
|
28 |
|
|
29 |
private ValidatorService getValidationService() { |
|
30 |
return this.validatorServiceLocator.getService(); |
|
31 |
} |
|
32 |
|
|
33 |
public ServiceLocator<ValidatorService> getValidatorServiceLocator() { |
|
34 |
return validatorServiceLocator; |
|
35 |
} |
|
36 |
|
|
37 |
public void setValidatorServiceLocator(ServiceLocator<ValidatorService> validatorServiceLocator) { |
|
38 |
this.validatorServiceLocator = validatorServiceLocator; |
|
39 |
} |
|
40 |
|
|
41 |
private Map<String, List<RuleSet>> rulesetMap = new ConcurrentHashMap<String, List<RuleSet>>(); |
|
42 |
|
|
43 |
@PostConstruct |
|
44 |
private void loadRules(){ |
|
45 |
|
|
46 |
try { |
|
47 |
for (RuleSet ruleSet : getValidationService().getRuleSets()) { |
|
48 |
if (ruleSet.getVisibility() != null && ruleSet.getVisibility().contains("development")) { |
|
49 |
String key = ""; |
|
50 |
if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0_data$")) |
|
51 |
key = Constants.VALIDATION_MODE_DATA; |
|
52 |
else if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0$") || ruleSet.getGuidelinesAcronym().equals("driver")) |
|
53 |
key = Constants.VALIDATION_MODE_LITERATURE; |
|
54 |
else if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0_cris$")) |
|
55 |
key = Constants.VALIDATION_MODE_CRIS; |
|
56 |
|
|
57 |
if (rulesetMap.containsKey(key)) |
|
58 |
rulesetMap.get(key).add(ruleSet); |
|
59 |
else { |
|
60 |
List<RuleSet> ruleSets = new ArrayList<RuleSet>(); |
|
61 |
ruleSets.add(ruleSet); |
|
62 |
rulesetMap.put(key, ruleSets); |
|
63 |
} |
|
64 |
} |
|
65 |
} |
|
66 |
} catch (ValidatorServiceException e) { |
|
67 |
e.printStackTrace(); |
|
68 |
} |
|
69 |
|
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public void submitJobForValidation(JobForValidation jobForValidation) { |
|
74 |
try { |
|
75 |
this.getValidationService().submitValidationJob(jobForValidation); |
|
76 |
} catch (ValidatorServiceException e) { |
|
77 |
e.printStackTrace(); |
|
78 |
} |
|
79 |
} |
|
80 |
|
|
81 |
@Override |
|
82 |
public void reSubmitJobForValidation(String jobId) { |
|
83 |
|
|
84 |
JSONObject jsonObject = new JSONObject(); |
|
85 |
jsonObject.put("jobId",jobId); |
|
86 |
jsonObject.put("groupBy","all"); |
|
87 |
|
|
88 |
StoredJob job = monitorApi.getJobSummary(jsonObject.toString()); |
|
89 |
Set<Integer> contentRules = new HashSet<Integer>(); |
|
90 |
Set<Integer> usageRules = new HashSet<Integer>(); |
|
91 |
|
|
92 |
RuleSet ruleSet = null; |
|
93 |
for (List<RuleSet> ruleSets : this.rulesetMap.values()) { |
|
94 |
for (RuleSet rSet : ruleSets) |
|
95 |
if (rSet.getGuidelinesAcronym().equals(job.getDesiredCompatibilityLevel())) { |
|
96 |
ruleSet = rSet; |
|
97 |
break; |
|
98 |
} |
|
99 |
} |
|
100 |
|
|
101 |
for (int ruleId : job.getRules()) { |
|
102 |
if (ruleSet.getContentRulesIds().contains(ruleId)) |
|
103 |
contentRules.add(ruleId); |
|
104 |
else if (ruleSet.getUsageRulesIds().contains(ruleId)) |
|
105 |
usageRules.add(ruleId); |
|
106 |
} |
|
107 |
if (!contentRules.isEmpty()) |
|
108 |
job.setSelectedContentRules(contentRules); |
|
109 |
if (!usageRules.isEmpty()) |
|
110 |
job.setSelectedUsageRules(usageRules); |
|
111 |
this.submitJobForValidation(job); |
|
112 |
} |
|
113 |
|
|
114 |
@Override |
|
115 |
public List<RuleSet> getRuleSets() { |
|
116 |
return rulesetMap.get(Constants.VALIDATION_MODE_DATA); |
|
117 |
} |
|
118 |
|
|
119 |
@Override |
|
120 |
public List<String> getSetsOfRepository(@PathVariable("url") String url) { |
|
121 |
try { |
|
122 |
return OaiTools.getSetsOfRepo(url); |
|
123 |
} catch (Exception e) { |
|
124 |
e.printStackTrace(); |
|
125 |
} |
|
126 |
return null; |
|
127 |
} |
|
128 |
|
|
129 |
} |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/rest/HelpApi.java | ||
---|---|---|
1 |
/* |
|
2 |
package eu.dnetlib.repo.manager.api.application.rest; |
|
3 |
|
|
4 |
import eu.dnetlib.domain.data.RepositoryInterface; |
|
5 |
import eu.dnetlib.gwt.shared.Help; |
|
6 |
import org.springframework.http.MediaType; |
|
7 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
8 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
9 |
import org.springframework.web.bind.annotation.RestController; |
|
10 |
|
|
11 |
@RestController |
|
12 |
@RequestMapping(value = "/help") |
|
13 |
public interface HelpApi { |
|
14 |
|
|
15 |
@RequestMapping(value = "/getHelpById/{id}", method = RequestMethod.GET, |
|
16 |
produces = MediaType.APPLICATION_JSON_VALUE) |
|
17 |
Help getHelpById(String id) ; |
|
18 |
|
|
19 |
} |
|
20 |
*/ |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/rest/MonitorApiImpl.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.service.rest; |
|
2 |
|
|
3 |
import eu.dnetlib.api.functionality.ValidatorService; |
|
4 |
import eu.dnetlib.api.functionality.ValidatorServiceException; |
|
5 |
import eu.dnetlib.domain.functionality.validator.StoredJob; |
|
6 |
import gr.uoa.di.driver.util.ServiceLocator; |
|
7 |
import org.json.JSONObject; |
|
8 |
import org.springframework.stereotype.Component; |
|
9 |
import java.util.List; |
|
10 |
|
|
11 |
@Component |
|
12 |
public class MonitorApiImpl implements MonitorApi { |
|
13 |
|
|
14 |
private ServiceLocator<ValidatorService> validatorServiceLocator; |
|
15 |
|
|
16 |
private ValidatorService getValidationService() { |
|
17 |
return this.validatorServiceLocator.getService(); |
|
18 |
} |
|
19 |
|
|
20 |
public ServiceLocator<ValidatorService> getValidatorServiceLocator() { |
|
21 |
return validatorServiceLocator; |
|
22 |
} |
|
23 |
|
|
24 |
public void setValidatorServiceLocator(ServiceLocator<ValidatorService> validatorServiceLocator) { |
|
25 |
this.validatorServiceLocator = validatorServiceLocator; |
|
26 |
} |
|
27 |
|
|
28 |
@Override |
|
29 |
public List<StoredJob> getJobsOfUser(String params) { |
|
30 |
JSONObject json_params = new JSONObject(params); |
|
31 |
|
|
32 |
String user = json_params.getString("user"); |
|
33 |
String jobType = json_params.getString("jobType"); |
|
34 |
Integer offset = Integer.parseInt(json_params.getString("offset")); |
|
35 |
Integer limit = Integer.parseInt(json_params.getString("limit")); |
|
36 |
String dateFrom = json_params.getString("dateFrom"); |
|
37 |
String dateTo = json_params.getString("dateTo"); |
|
38 |
String validationStatus = json_params.getString("validationStatus"); |
|
39 |
|
|
40 |
List<StoredJob> jobs = null; |
|
41 |
try { |
|
42 |
jobs = getValidationService(). |
|
43 |
getStoredJobsNew(user, jobType, offset, limit, dateFrom, dateTo, validationStatus); |
|
44 |
} catch (ValidatorServiceException e) { |
|
45 |
e.printStackTrace(); |
|
46 |
} |
|
47 |
return jobs; |
|
48 |
|
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public int getJobsOfUserPerValidationStatus(String params) { |
|
53 |
JSONObject json_params = new JSONObject(params); |
|
54 |
|
|
55 |
String user = json_params.getString("user"); |
|
56 |
String jobType = json_params.getString("jobType"); |
|
57 |
String validationStatus = json_params.getString("validationStatus"); |
|
58 |
try { |
|
59 |
return getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus); |
|
60 |
} catch (ValidatorServiceException e) { |
|
61 |
e.printStackTrace(); |
|
62 |
} |
|
63 |
return 0; |
|
64 |
} |
|
65 |
|
|
66 |
@Override |
|
67 |
public StoredJob getJobSummary(String params) { |
|
68 |
JSONObject json_params = new JSONObject(params); |
|
69 |
|
|
70 |
String jobId = json_params.getString("jobId"); |
|
71 |
String groupBy = json_params.getString("groupBy"); |
|
72 |
|
|
73 |
try { |
|
74 |
return getValidationService().getStoredJob(Integer.parseInt(jobId), groupBy); |
|
75 |
} catch (ValidatorServiceException e) { |
|
76 |
e.printStackTrace(); |
|
77 |
} |
|
78 |
return null; |
|
79 |
} |
|
80 |
|
|
81 |
} |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/rest/HelpApiImpl.java | ||
---|---|---|
1 |
/* |
|
2 |
package eu.dnetlib.repo.manager.api.application.rest; |
|
3 |
|
|
4 |
import eu.dnetlib.gwt.client.help.HelpServiceAsync; |
|
5 |
import eu.dnetlib.gwt.shared.Help; |
|
6 |
import org.springframework.beans.factory.annotation.Autowired; |
|
7 |
import org.springframework.stereotype.Component; |
|
8 |
import org.springframework.web.bind.annotation.PathVariable; |
|
9 |
|
|
10 |
@Component |
|
11 |
public class HelpApiImpl implements HelpApi{ |
|
12 |
|
|
13 |
@Autowired |
|
14 |
private static HelpServiceAsync helpService; |
|
15 |
|
|
16 |
@Override |
|
17 |
public Help getHelpById(@PathVariable("id") String id) { |
|
18 |
return null; |
|
19 |
} |
|
20 |
|
|
21 |
} |
|
22 |
*/ |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/rest/RepositoryApi.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.service.rest; |
|
2 |
|
|
3 |
import eu.dnetlib.domain.data.Repository; |
|
4 |
import eu.dnetlib.domain.data.RepositoryInterface; |
|
5 |
import org.springframework.http.MediaType; |
|
6 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
7 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
8 |
import org.springframework.web.bind.annotation.RestController; |
|
9 |
import java.util.List; |
|
10 |
|
|
11 |
@RestController |
|
12 |
@RequestMapping(value = "/repository") |
|
13 |
public interface RepositoryApi { |
|
14 |
|
|
15 |
@RequestMapping(value = "/getCountries", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) |
|
16 |
String getCountries() ; |
|
17 |
|
|
18 |
@RequestMapping(value = "/getRepositoriesByCountry/{country}/{page}/{size}/", method = RequestMethod.GET, |
|
19 |
produces = MediaType.APPLICATION_JSON_VALUE) |
|
20 |
List<Repository> getRepositoriesByCountry(String country, |
|
21 |
String page, |
|
22 |
String size) ; |
|
23 |
|
|
24 |
@RequestMapping(value = "/getRepositoriesOfUser/{userEmail}/{page}/{size}") |
|
25 |
List<Repository> getRepositoriesOfUser( String userEmail, |
|
26 |
String page, |
|
27 |
String size); |
|
28 |
|
|
29 |
@RequestMapping(value = "/getRepositoryById/{id}", method = RequestMethod.GET, |
|
30 |
produces = MediaType.APPLICATION_JSON_VALUE) |
|
31 |
Repository getRepositoryById(String id) ; |
|
32 |
|
|
33 |
@RequestMapping(value = "/getRepositoriesByName/{name}/{page}/{size}/", method = RequestMethod.GET, |
|
34 |
produces = MediaType.APPLICATION_JSON_VALUE) |
|
35 |
List<Repository> getRepositoriesByName(String name, |
|
36 |
String page, |
|
37 |
String size); |
|
38 |
|
|
39 |
@RequestMapping(value = "/getRepositoryInterface/{id}", method = RequestMethod.GET, |
|
40 |
produces = MediaType.APPLICATION_JSON_VALUE) |
|
41 |
RepositoryInterface getRepositoyInterface(String id) ; |
|
42 |
|
|
43 |
@RequestMapping(value = "/addRepository", method = RequestMethod.POST, |
|
44 |
consumes = MediaType.APPLICATION_JSON_VALUE) |
|
45 |
String addRepository(Repository repository); |
|
46 |
|
|
47 |
@RequestMapping(value = "/addInterface", method = RequestMethod.POST, |
|
48 |
consumes = MediaType.APPLICATION_JSON_VALUE) |
|
49 |
String addRepositoryInterface(RepositoryInterface repositoryInterface); |
|
50 |
|
|
51 |
@RequestMapping(value = "/getDnetCountries", method = RequestMethod.GET, |
|
52 |
produces = MediaType.APPLICATION_JSON_VALUE) |
|
53 |
List<String> getDnetCountries(); |
|
54 |
|
|
55 |
@RequestMapping(value = "/getTypologies", method = RequestMethod.GET, |
|
56 |
produces = MediaType.APPLICATION_JSON_VALUE) |
|
57 |
List<String> getTypologies(); |
|
58 |
|
|
59 |
@RequestMapping(value = "/getTimezones", method = RequestMethod.GET, |
|
60 |
produces = MediaType.APPLICATION_JSON_VALUE) |
|
61 |
List<String> getTimezones(); |
|
62 |
|
|
63 |
@RequestMapping(value = "/updateManagedStatus", method = RequestMethod.POST, |
|
64 |
produces = MediaType.APPLICATION_JSON_VALUE) |
|
65 |
String updateManagedStatus(String id,String managed); |
|
66 |
|
|
67 |
@RequestMapping(value = "/updateEnglishName", method = RequestMethod.POST, |
|
68 |
produces = MediaType.APPLICATION_JSON_VALUE) |
|
69 |
String updateEnglishName(String id,String englishName); |
|
70 |
|
|
71 |
@RequestMapping(value = "/updateLatitude", method = RequestMethod.POST, |
|
72 |
produces = MediaType.APPLICATION_JSON_VALUE) |
|
73 |
String updateLatitude(String id,String latitude); |
|
74 |
|
|
75 |
@RequestMapping(value = "/updateLongitude", method = RequestMethod.POST, |
|
76 |
produces = MediaType.APPLICATION_JSON_VALUE) |
|
77 |
String updateLongitude(String id,String longitude); |
|
78 |
|
|
79 |
@RequestMapping(value = "/updateOfficialName", method = RequestMethod.POST, |
|
80 |
produces = MediaType.APPLICATION_JSON_VALUE) |
|
81 |
String updateOfficialName(String id,String officialName); |
|
82 |
|
|
83 |
@RequestMapping(value = "/getUrlsOfUserRepos",method = RequestMethod.GET, |
|
84 |
produces = MediaType.APPLICATION_JSON_VALUE) |
|
85 |
String getUrlsOfUserRepos(String user_email); |
|
86 |
|
|
87 |
} |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/rest/RepositoryApiImpl.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.service.rest; |
|
2 |
|
|
3 |
import eu.dnetlib.repo.manager.service.shared.BrokerException; |
|
4 |
import eu.dnetlib.repo.manager.service.shared.broker.BrowseEntry; |
|
5 |
import eu.dnetlib.repo.manager.service.utils.Converter; |
|
6 |
import eu.dnetlib.domain.data.Repository; |
|
7 |
import eu.dnetlib.domain.data.RepositoryInterface; |
|
8 |
import org.json.JSONArray; |
|
9 |
import org.json.JSONObject; |
|
10 |
import org.springframework.beans.factory.annotation.Value; |
|
11 |
import org.springframework.core.ParameterizedTypeReference; |
|
12 |
import org.springframework.http.HttpMethod; |
|
13 |
import org.springframework.http.ResponseEntity; |
|
14 |
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; |
|
15 |
import org.springframework.stereotype.Component; |
|
16 |
import org.springframework.web.bind.annotation.PathVariable; |
|
17 |
import org.springframework.web.bind.annotation.RequestBody; |
|
18 |
import org.springframework.web.bind.annotation.RequestParam; |
|
19 |
import org.springframework.web.client.RestClientException; |
|
20 |
import org.springframework.web.client.RestTemplate; |
|
21 |
import org.springframework.web.util.UriComponents; |
|
22 |
import org.springframework.web.util.UriComponentsBuilder; |
|
23 |
|
|
24 |
import javax.annotation.PostConstruct; |
|
25 |
import javax.ws.rs.core.UriBuilder; |
|
26 |
import java.util.List; |
|
27 |
|
|
28 |
|
|
29 |
@Component |
|
30 |
public class RepositoryApiImpl implements RepositoryApi { |
|
31 |
|
|
32 |
@Value("${api.baseAddress}") |
|
33 |
private String baseAddress; |
|
34 |
|
|
35 |
private RestTemplate restTemplate = null; |
|
36 |
|
|
37 |
@PostConstruct |
|
38 |
private void init(){ |
|
39 |
restTemplate = new RestTemplate(); |
|
40 |
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
public String getCountries() { |
|
45 |
UriComponents uriComponents = UriComponentsBuilder |
|
46 |
.fromHttpUrl(baseAddress + "/ds/countries") |
|
47 |
.build().encode(); |
|
48 |
return restTemplate.getForObject(uriComponents.toUri(), String.class); |
|
49 |
} |
|
50 |
|
|
51 |
|
|
52 |
@Override |
|
53 |
public List<Repository> getRepositoriesByCountry(@PathVariable("country") String country, |
|
54 |
@PathVariable("page") String page, |
|
55 |
@PathVariable("size") String size){ |
|
56 |
/* String vars = page+"/"+size+"?country="+country; |
|
57 |
String uri = baseAddress+ "/ds/search/country/" + vars; |
|
58 |
JSONArray jsonArray = new JSONArray(RestService.executeGET(uri)); |
|
59 |
return Converter.jsonToRepositoryList(jsonArray);*/ |
|
60 |
|
|
61 |
UriComponents uriComponents = UriComponentsBuilder |
|
62 |
.fromHttpUrl(baseAddress + "/ds/search/country/") |
|
63 |
.path("/{page}/{size}/") |
|
64 |
.queryParam("country",country) |
|
65 |
.build().expand(page,size).encode(); |
|
66 |
|
|
67 |
RestTemplate template = new RestTemplate(); |
|
68 |
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); |
|
69 |
|
|
70 |
String rs = template.getForObject(uriComponents.toUri(), String.class); |
|
71 |
return Converter.jsonToRepositoryList(new JSONArray(rs)); |
|
72 |
} |
|
73 |
|
|
74 |
@Override |
|
75 |
public List<Repository> getRepositoriesOfUser(@PathVariable("userEmail") String userEmail, |
|
76 |
@PathVariable("page") String page, |
|
77 |
@PathVariable("size") String size) { |
|
78 |
String vars = page+"/"+size+"?contactemail="+userEmail; |
|
79 |
String uri = baseAddress+ "/ds/search/email/" + vars; |
|
80 |
JSONArray jsonArray = new JSONArray(RestService.executeGET(uri)); |
|
81 |
return Converter.jsonToRepositoryList(jsonArray); |
|
82 |
} |
|
83 |
|
|
84 |
@Override |
|
85 |
public Repository getRepositoryById(@PathVariable("id") String id) { |
|
86 |
String uri = baseAddress+ "/ds/get/" + id; |
|
87 |
JSONObject jsonObject = new JSONObject( RestService.executeGET(uri) ); |
|
88 |
return Converter.jsonToRepositoryObject(jsonObject); |
|
89 |
} |
|
90 |
|
|
91 |
@Override |
|
92 |
public List<Repository> getRepositoriesByName(@PathVariable("name") String name, |
|
93 |
@PathVariable("page") String page, |
|
94 |
@PathVariable("size") String size) { |
|
95 |
String vars = page+"/"+size+"?name="+name; |
|
96 |
String uri = baseAddress+ "/ds/search/name/" + vars; |
|
97 |
JSONArray jsonArray = new JSONArray(RestService.executeGET(uri)); |
|
98 |
return Converter.jsonToRepositoryList(jsonArray); |
|
99 |
} |
|
100 |
|
|
101 |
@Override |
|
102 |
public RepositoryInterface getRepositoyInterface(@PathVariable("id") String id) { |
|
103 |
String uri = baseAddress+ "/ds/service/" + id; |
|
104 |
JSONArray jsonArray = new JSONArray( RestService.executeGET(uri) ); |
|
105 |
return Converter.jsonToRepositoryInterfaceObject(jsonArray.getJSONObject(0)); |
|
106 |
} |
|
107 |
|
|
108 |
@Override |
|
109 |
public String addRepository(@RequestBody Repository repository) { |
|
110 |
String uri = baseAddress+ "/ds/add/"; |
|
111 |
return RestService.executePOST(uri, Converter.repositoryObjectToJson(repository)); |
|
112 |
} |
|
113 |
|
|
114 |
@Override |
|
115 |
public String addRepositoryInterface(RepositoryInterface repositoryInterface) { |
|
116 |
String uri = baseAddress+ "/ds/service/add/"; |
|
117 |
return RestService.executePOST(uri, Converter.repositoryInterfaceObjectToJson(repositoryInterface)); |
|
118 |
} |
|
119 |
|
|
120 |
@Override |
|
121 |
public List<String> getDnetCountries() { |
|
122 |
return Converter.readFile("countries.txt"); |
|
123 |
} |
|
124 |
|
|
125 |
@Override |
|
126 |
public List<String> getTypologies() { |
|
127 |
System.out.println("Typologies"); |
|
128 |
return Converter.readFile("typologies.txt"); |
|
129 |
} |
|
130 |
|
|
131 |
@Override |
|
132 |
public List<String> getTimezones() { |
|
133 |
return Converter.readFile("timezones.txt"); |
|
134 |
} |
|
135 |
|
|
136 |
@Override |
|
137 |
public String updateManagedStatus(@RequestParam(value = "id") String id, |
|
138 |
@RequestParam(value = "managed") String managed) { |
|
139 |
String uri = baseAddress+ "/ds/manage?id="+id+"&managed="+managed; |
|
140 |
return RestService.executePOST(uri,null); |
|
141 |
} |
|
142 |
|
|
143 |
@Override |
|
144 |
public String updateEnglishName(@RequestParam(value = "id") String id, |
|
145 |
@RequestParam(value = "englishname") String englishName) { |
|
146 |
String uri = baseAddress+ "/ds/manage?dsId="+id+"&englishname="+englishName; |
|
147 |
return RestService.executePOST(uri,null); |
|
148 |
} |
|
149 |
|
|
150 |
@Override |
|
151 |
public String updateLatitude(@RequestParam(value = "id") String id, |
|
152 |
@RequestParam(value = "managed") String latitude) { |
|
153 |
String uri = baseAddress+ "/ds/manage?dsId="+id+"&latitude="+latitude; |
|
154 |
return RestService.executePOST(uri,null); |
|
155 |
} |
|
156 |
|
|
157 |
@Override |
|
158 |
public String updateLongitude(@RequestParam(value = "id") String id, |
|
159 |
@RequestParam(value = "longitude") String longitude) { |
|
160 |
String uri = baseAddress+ "/ds/manage?dsId="+id+"&longitude="+longitude; |
|
161 |
return RestService.executePOST(uri,null); |
|
162 |
} |
|
163 |
|
|
164 |
@Override |
|
165 |
public String updateOfficialName(@RequestParam(value = "id") String id, |
|
166 |
@RequestParam(value = "officialname") String officialname) { |
|
167 |
String uri = baseAddress+ "/ds/manage?dsId="+id+"&officialname="+officialname; |
|
168 |
return RestService.executePOST(uri,null); |
|
169 |
} |
|
170 |
|
|
171 |
@Override |
|
172 |
public String getUrlsOfUserRepos(@PathVariable("user_email") String user_email) { |
|
173 |
|
|
174 |
//TODO create service a join datasource d for user u method |
|
175 |
|
|
176 |
return null; |
|
177 |
} |
|
178 |
|
|
179 |
|
|
180 |
} |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/rest/BrokerApi.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.service.rest; |
|
2 |
|
|
3 |
import eu.dnetlib.repo.manager.service.shared.BrokerException; |
|
4 |
import eu.dnetlib.repo.manager.service.shared.broker.BrowseEntry; |
|
5 |
import eu.dnetlib.repo.manager.service.shared.broker.DatasourcesBroker; |
|
6 |
import eu.dnetlib.repo.manager.service.shared.broker.EventsPage; |
|
7 |
import org.springframework.http.MediaType; |
|
8 |
import org.springframework.web.bind.annotation.RequestBody; |
|
9 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
10 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
11 |
import org.springframework.web.bind.annotation.RestController; |
|
12 |
|
|
13 |
import java.util.List; |
|
14 |
|
|
15 |
@RestController |
|
16 |
@RequestMapping(value = "/broker") |
|
17 |
public interface BrokerApi { |
|
18 |
|
|
19 |
@RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) |
|
20 |
DatasourcesBroker getDatasourcesOfUser(@RequestBody String params) throws BrokerException; |
|
21 |
|
|
22 |
@RequestMapping(value = "/getTopicsForDatasource/{datasourceName}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) |
|
23 |
List<BrowseEntry> getTopicsForDatasource(String datasourceName) throws BrokerException; |
|
24 |
|
|
25 |
@RequestMapping(value = "/advancedShowEvents" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) |
|
26 |
EventsPage advancedShowEvents(@RequestBody String params) throws BrokerException; |
|
27 |
} |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/rest/RestService.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.service.rest; |
|
2 |
|
|
3 |
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; |
|
4 |
import org.springframework.stereotype.Component; |
|
5 |
import org.springframework.web.client.RestTemplate; |
|
6 |
|
|
7 |
@Component |
|
8 |
public class RestService { |
|
9 |
|
|
10 |
private static RestTemplate restTemplate = new org.springframework.web.client.RestTemplate(); |
|
11 |
|
|
12 |
|
|
13 |
public static String executeGET(String uri){ |
|
14 |
return restTemplate.getForObject(uri,String.class); |
|
15 |
} |
|
16 |
|
|
17 |
public static String executePOST(String uri,String json){ |
|
18 |
return restTemplate.postForObject(uri,json,String.class); |
|
19 |
} |
|
20 |
} |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/rest/ValidatorApi.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.service.rest; |
|
2 |
|
|
3 |
import eu.dnetlib.domain.functionality.validator.JobForValidation; |
|
4 |
import eu.dnetlib.domain.functionality.validator.RuleSet; |
|
5 |
import org.springframework.http.MediaType; |
|
6 |
import org.springframework.web.bind.annotation.RequestBody; |
|
7 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
8 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
9 |
import org.springframework.web.bind.annotation.RestController; |
|
10 |
|
|
11 |
import java.util.List; |
|
12 |
|
|
13 |
|
|
14 |
@RestController |
|
15 |
@RequestMapping(value = "/validator") |
|
16 |
public interface ValidatorApi { |
|
17 |
|
|
18 |
@RequestMapping(value = "/submitJobForValidation",method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE ) |
|
19 |
void submitJobForValidation(@RequestBody JobForValidation jobForValidation); |
|
20 |
|
|
21 |
@RequestMapping(value = "/reSubmitJobForValidation/",method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE ) |
|
22 |
void reSubmitJobForValidation(@RequestBody String jobId); |
|
23 |
|
|
24 |
@RequestMapping(value = "/getRuleSets" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) |
|
25 |
List<RuleSet> getRuleSets(); |
|
26 |
|
|
27 |
@RequestMapping(value = "/getSetsOfRepository/{url}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) |
|
28 |
List<String> getSetsOfRepository(String url); |
|
29 |
|
|
30 |
} |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/rest/BrokerApiImpl.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.service.rest; |
|
2 |
|
|
3 |
|
|
4 |
import com.fasterxml.jackson.databind.ObjectMapper; |
|
5 |
import com.google.gson.Gson; |
|
6 |
import eu.dnetlib.domain.data.Repository; |
|
7 |
import eu.dnetlib.repo.manager.service.shared.BrokerException; |
|
8 |
import eu.dnetlib.repo.manager.service.shared.Tuple; |
|
9 |
import eu.dnetlib.repo.manager.service.shared.broker.AdvQueryObject; |
|
10 |
import eu.dnetlib.repo.manager.service.shared.broker.BrowseEntry; |
|
11 |
import eu.dnetlib.repo.manager.service.shared.broker.DatasourcesBroker; |
|
12 |
import eu.dnetlib.repo.manager.service.shared.broker.EventsPage; |
|
13 |
import org.json.JSONObject; |
|
14 |
import org.springframework.beans.factory.annotation.Autowired; |
|
15 |
import org.springframework.beans.factory.annotation.Value; |
|
16 |
import org.springframework.core.ParameterizedTypeReference; |
|
17 |
import org.springframework.http.HttpEntity; |
|
18 |
import org.springframework.http.HttpMethod; |
|
19 |
import org.springframework.http.ResponseEntity; |
|
20 |
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; |
|
21 |
import org.springframework.stereotype.Component; |
|
22 |
import org.springframework.util.LinkedMultiValueMap; |
|
23 |
import org.springframework.util.MultiValueMap; |
|
24 |
import org.springframework.web.bind.annotation.PathVariable; |
|
25 |
import org.springframework.web.client.RestClientException; |
|
26 |
import org.springframework.web.client.RestTemplate; |
|
27 |
import org.springframework.web.util.UriComponentsBuilder; |
|
28 |
|
|
29 |
import java.util.*; |
|
30 |
|
|
31 |
@Component |
|
32 |
public class BrokerApiImpl implements BrokerApi { |
|
33 |
|
|
34 |
|
|
35 |
@Autowired |
|
36 |
private RepositoryApiImpl repoAPI; |
|
37 |
@Value("${services.broker.url}:${services.broker.port}/${services.broker.api}${services.broker.openaire}") |
|
38 |
private String openairePath; |
|
39 |
|
|
40 |
@Override |
|
41 |
public DatasourcesBroker getDatasourcesOfUser(String params) { |
|
42 |
JSONObject json_params = new JSONObject(params); |
|
43 |
DatasourcesBroker ret = new DatasourcesBroker(); |
|
44 |
|
|
45 |
String userEmail = json_params.getString("userEmail"); |
|
46 |
boolean includeShared = json_params.getBoolean("includeShared"); |
|
47 |
boolean includeByOthers = json_params.getBoolean("includeByOthers"); |
|
48 |
|
|
49 |
try { |
|
50 |
ret.setDatasourcesOfUser(getDatasourcesOfUserType(getRepositoriesOfUser(userEmail))); |
|
51 |
if (includeShared) { |
|
52 |
//TODO whatever nikonas was saying |
|
53 |
List<String> sharedDatasourceIds = new ArrayList<String>(); |
|
54 |
ret.setSharedDatasources(getDatasourcesOfUserType(getRepositoriesByIds(sharedDatasourceIds))); |
|
55 |
} |
|
56 |
|
|
57 |
if (includeByOthers) { |
|
58 |
ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(userEmail))); |
|
59 |
} |
|
60 |
} catch (BrokerException e) { |
|
61 |
e.printStackTrace(); |
|
62 |
} |
|
63 |
|
|
64 |
return ret; |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public List<BrowseEntry> getTopicsForDatasource(@PathVariable("datasourceName") String datasourceName) throws BrokerException { |
|
69 |
final String service = "/topicsForDatasource"; |
|
70 |
|
|
71 |
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service) |
|
72 |
.queryParam("ds", datasourceName); |
|
73 |
|
|
74 |
RestTemplate template = new RestTemplate(); |
|
75 |
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); |
|
76 |
ResponseEntity<List<BrowseEntry>> resp; |
|
77 |
try { |
|
78 |
resp = template.exchange( |
|
79 |
builder.build().encode().toUri(), |
|
80 |
HttpMethod.GET, |
|
81 |
null, |
|
82 |
new ParameterizedTypeReference<List<BrowseEntry>>() { |
|
83 |
}); |
|
84 |
} catch (RestClientException e) { |
|
85 |
throw new BrokerException(e); |
|
86 |
} |
|
87 |
|
|
88 |
return resp.getBody(); |
|
89 |
} |
|
90 |
|
|
91 |
@Override |
|
92 |
public EventsPage advancedShowEvents(String params) throws BrokerException { |
|
93 |
JSONObject json_params = new JSONObject(params); |
|
94 |
|
|
95 |
long page = json_params.getLong("page"); |
|
96 |
long pagesize = json_params.getLong("pagesize"); |
|
97 |
|
|
98 |
JSONObject json_advQueryObject = json_params.getJSONObject("advQueryObject"); |
|
99 |
ObjectMapper obj = new ObjectMapper(); |
|
100 |
AdvQueryObject advQueryObject = new Gson().fromJson(json_advQueryObject.toString(),AdvQueryObject.class); |
|
101 |
|
|
102 |
|
|
103 |
final String service = "/events/{page}/{pageSize}"; |
|
104 |
|
|
105 |
Map<String, Long> uriParams = new HashMap<>(); |
|
106 |
uriParams.put("page", page); |
|
107 |
uriParams.put("pageSize", pagesize); |
|
108 |
|
|
109 |
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service); |
|
110 |
|
|
111 |
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); |
|
112 |
headers.add("Content-Type", "application/json"); |
|
113 |
|
|
114 |
advQueryObject.setPage(page); |
|
115 |
|
|
116 |
HttpEntity<AdvQueryObject> entity = new HttpEntity<>(advQueryObject, headers); |
|
117 |
|
|
118 |
RestTemplate template = new RestTemplate(); |
|
119 |
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); |
|
120 |
ResponseEntity<EventsPage> resp; |
|
121 |
try { |
|
122 |
resp = template.exchange( |
|
123 |
builder.buildAndExpand(uriParams).encode().toUri(), |
|
124 |
HttpMethod.POST, |
|
125 |
entity, |
|
126 |
new ParameterizedTypeReference<EventsPage>() { |
|
127 |
} |
|
128 |
); |
|
129 |
} catch (RestClientException e) { |
|
130 |
throw new BrokerException(e); |
|
131 |
} |
|
132 |
return resp.getBody(); |
|
133 |
|
|
134 |
|
|
135 |
} |
|
136 |
|
|
137 |
|
|
138 |
private List<Tuple<BrowseEntry, String>> getDatasourcesOfUserType(List<Repository> repositories) throws BrokerException { |
|
139 |
|
|
140 |
List<Tuple<BrowseEntry, String>> entries = new ArrayList<>(); |
|
141 |
for (Repository repo : repositories) { |
|
142 |
BrowseEntry temp = new BrowseEntry(); |
|
143 |
temp.setValue(repo.getOfficialName()); |
|
144 |
temp.setSize(new Long(0)); |
|
145 |
for (BrowseEntry e : getTopicsForDatasource(repo.getOfficialName())) { |
|
146 |
temp.setSize(temp.getSize() + e.getSize()); |
|
147 |
} |
|
148 |
Tuple<BrowseEntry, String> tup = new Tuple<>(temp, repo.getLogoUrl()); |
|
149 |
entries.add(tup); |
|
150 |
} |
|
151 |
|
|
152 |
// sort the collection by the second field of the tuple which is size |
|
153 |
Collections.sort(entries, new Comparator<Tuple<BrowseEntry, String>>() { |
|
154 |
@Override |
|
155 |
public int compare(Tuple<BrowseEntry, String> e1, Tuple<BrowseEntry, String> e2) { |
|
156 |
return (int) (e2.getFirst().getSize().longValue() - e1.getFirst().getSize().longValue()); |
|
157 |
} |
|
158 |
}); |
|
159 |
|
|
160 |
return entries; |
|
161 |
} |
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
private List<Repository> getRepositoriesOfUser(String userEmail){ |
|
166 |
|
|
167 |
int page = 1; |
|
168 |
int size = 10; |
|
169 |
List<Repository> rs = null; |
|
170 |
List<Repository> resultSet = new ArrayList<>(); |
|
171 |
|
|
172 |
while (true){ |
|
173 |
rs = repoAPI.getRepositoriesOfUser(userEmail, String.valueOf(page), String.valueOf(size)); |
|
174 |
if(rs.size() == 0) break; |
|
175 |
resultSet.addAll(rs); |
|
176 |
} |
|
177 |
return resultSet; |
|
178 |
} |
|
179 |
|
|
180 |
private List<Repository> getRepositoriesByIds(List<String> sharedDatasourceIds) { |
|
181 |
return null; |
|
182 |
} |
|
183 |
|
|
184 |
} |
modules/uoa-repository-manager-service/src/main/resources/eu/dnetlib/repo/manager/service/typologies.txt | ||
---|---|---|
1 |
CONTENTdm |
|
2 |
Digibib |
|
3 |
Digital Commons |
|
4 |
DigiTool |
|
5 |
DIVA |
|
6 |
Diva-Portal |
|
7 |
dLibra |
|
8 |
Doks |
|
9 |
Drupal |
|
10 |
DSpace |
|
11 |
Earmas |
|
12 |
EPrints |
|
13 |
ETD |
|
14 |
ETD-db |
|
15 |
Fedora |
|
16 |
Fez |
|
17 |
Greenstone |
|
18 |
HAL |
|
19 |
invenio |
|
20 |
MyCoRe |
|
21 |
Open Repository |
|
22 |
OPUS |
|
23 |
Pica-Verbundkatalog |
|
24 |
Proprietary Software |
|
25 |
PUMA |
|
26 |
PURE |
|
27 |
SciELO |
|
28 |
SFIX |
|
29 |
VITAL |
|
30 |
VTOAI |
|
31 |
WEKO |
|
32 |
XooNIps |
|
33 |
------------------------ |
|
34 |
OJS |
|
35 |
HyperJournal |
|
36 |
ePubTk |
|
37 |
GAPworks |
|
38 |
DPubS |
|
39 |
E-Journal |
|
40 |
------------------------ |
|
41 |
[Other] |
|
42 |
|
modules/uoa-repository-manager-service/src/main/resources/eu/dnetlib/repo/manager/service/countries.txt | ||
---|---|---|
1 |
Afghanistan |
|
2 |
Albania |
|
3 |
Algeria |
|
4 |
Andorra |
|
5 |
Angola |
|
6 |
Antigua & Deps |
|
7 |
Argentina |
|
8 |
Armenia |
|
9 |
Australia |
|
10 |
Austria |
|
11 |
Azerbaijan |
|
12 |
Bahamas |
|
13 |
Bahrain |
|
14 |
Bangladesh |
|
15 |
Barbados |
|
16 |
Belarus |
|
17 |
Belgium |
|
18 |
Belize |
|
19 |
Benin |
|
20 |
Bhutan |
|
21 |
Bolivia |
|
22 |
Bosnia Herzegovina |
|
23 |
Botswana |
|
24 |
Brazil |
|
25 |
Brunei |
|
26 |
Bulgaria |
|
27 |
Burkina |
|
28 |
Burundi |
|
29 |
Cambodia |
|
30 |
Cameroon |
|
31 |
Canada |
|
32 |
Cape Verde |
|
33 |
Central African Rep |
|
34 |
Chad |
|
35 |
Chile |
|
36 |
China |
|
37 |
Colombia |
|
38 |
Comoros |
|
39 |
Congo |
|
40 |
Congo {Democratic Rep} |
|
41 |
Costa Rica |
|
42 |
Croatia |
|
43 |
Cuba |
|
44 |
Cyprus |
|
45 |
Czech Republic |
|
46 |
Denmark |
|
47 |
Djibouti |
|
48 |
Dominica |
|
49 |
Dominican Republic |
|
50 |
East Timor |
|
51 |
Ecuador |
|
52 |
Egypt |
|
53 |
El Salvador |
|
54 |
Equatorial Guinea |
|
55 |
Eritrea |
|
56 |
Estonia |
|
57 |
Ethiopia |
|
58 |
Fiji |
|
59 |
Finland |
|
60 |
France |
|
61 |
Gabon |
|
62 |
Gambia |
|
63 |
Georgia |
|
64 |
Germany |
|
65 |
Ghana |
|
66 |
Greece |
|
67 |
Grenada |
|
68 |
Guatemala |
|
69 |
Guinea |
|
70 |
Guinea-Bissau |
|
71 |
Guyana |
|
72 |
Haiti |
|
73 |
Honduras |
|
74 |
Hungary |
|
75 |
Iceland |
|
76 |
India |
|
77 |
Indonesia |
|
78 |
Iran |
|
79 |
Iraq |
|
80 |
Ireland {Republic} |
|
81 |
Israel |
|
82 |
Italy |
|
83 |
Ivory Coast |
|
84 |
Jamaica |
|
85 |
Japan |
|
86 |
Jordan |
|
87 |
Kazakhstan |
|
88 |
Kenya |
|
89 |
Kiribati |
|
90 |
Korea North |
|
91 |
Korea South |
|
92 |
Kosovo |
|
93 |
Kuwait |
|
94 |
Kyrgyzstan |
|
95 |
Laos |
|
96 |
Latvia |
|
97 |
Lebanon |
|
98 |
Lesotho |
|
99 |
Liberia |
|
100 |
Libya |
|
101 |
Liechtenstein |
|
102 |
Lithuania |
|
103 |
Luxembourg |
|
104 |
Macedonia |
|
105 |
Madagascar |
|
106 |
Malawi |
|
107 |
Malaysia |
|
108 |
Maldives |
|
109 |
Mali |
|
110 |
Malta |
|
111 |
Marshall Islands |
|
112 |
Mauritania |
|
113 |
Mauritius |
|
114 |
Mexico |
|
115 |
Micronesia |
|
116 |
Moldova |
|
117 |
Monaco |
|
118 |
Mongolia |
|
119 |
Montenegro |
|
120 |
Morocco |
|
121 |
Mozambique |
|
122 |
Myanmar, {Burma} |
|
123 |
Namibia |
|
124 |
Nauru |
|
125 |
Nepal |
|
126 |
Netherlands |
|
127 |
New Zealand |
|
128 |
Nicaragua |
|
129 |
Niger |
|
130 |
Nigeria |
|
131 |
Norway |
|
132 |
Oman |
|
133 |
Pakistan |
|
134 |
Palau |
|
135 |
Panama |
|
136 |
Papua New Guinea |
|
137 |
Paraguay |
|
138 |
Peru |
|
139 |
Philippines |
|
140 |
Poland |
|
141 |
Portugal |
|
142 |
Qatar |
|
143 |
Romania |
|
144 |
Russian Federation |
|
145 |
Rwanda |
|
146 |
St Kitts & Nevis |
|
147 |
St Lucia |
|
148 |
Saint Vincent & the Grenadines |
|
149 |
Samoa |
|
150 |
San Marino |
|
151 |
Sao Tome & Principe |
|
152 |
Saudi Arabia |
|
153 |
Senegal |
|
154 |
Serbia |
|
155 |
Seychelles |
|
156 |
Sierra Leone |
|
157 |
Singapore |
|
158 |
Slovakia |
|
159 |
Slovenia |
|
160 |
Solomon Islands |
|
161 |
Somalia |
|
162 |
South Africa |
|
163 |
Spain |
|
164 |
Sri Lanka |
|
165 |
Sudan |
|
166 |
Suriname |
|
167 |
Swaziland |
|
168 |
Sweden |
|
169 |
Switzerland |
|
170 |
Syria |
|
171 |
Taiwan |
|
172 |
Tajikistan |
|
173 |
Tanzania |
|
174 |
Thailand |
|
175 |
Togo |
|
176 |
Tonga |
|
177 |
Trinidad & Tobago |
|
178 |
Tunisia |
|
179 |
Turkey |
|
180 |
Turkmenistan |
|
181 |
Tuvalu |
|
182 |
Uganda |
|
183 |
Ukraine |
|
184 |
United Arab Emirates |
|
185 |
United Kingdom |
|
186 |
United States |
|
187 |
Uruguay |
|
188 |
Uzbekistan |
|
189 |
Vanuatu |
|
190 |
Vatican City |
|
191 |
Venezuela |
|
192 |
Vietnam |
|
193 |
Yemen |
|
194 |
Zambia |
|
195 |
Zimbabwe |
modules/uoa-repository-manager-service/src/main/resources/eu/dnetlib/repo/manager/service/timezones.txt | ||
---|---|---|
1 |
-2.0 [GMT - 2] Fernando de Noronha Time, South Georg... |
|
2 |
-1.0 [GMT - 1] Azores Standard Time, Cape Verde Time... |
|
3 |
0.0 [GMT] Western European Time, Greenwich Mean Time |
|
4 |
1.0 [GMT + 1] Central European Time, West African Time |
|
5 |
2.0 [GMT + 2] Eastern European Time, Central Africa... |
|
6 |
3.0 [GMT + 3] Moscow Standard Time, Eastern African... |
|
7 |
3.5 [GMT + 3:30] Iran Standard Time |
|
8 |
4.0 [GMT + 4] Gulf Standard Time, Samara Standard Time |
|
9 |
4.5 [GMT + 4:30] Afghanistan Time |
|
10 |
5.0 [GMT + 5] Pakistan Standard Time, Yekaterinburg... |
|
11 |
8.0 [GMT + 8] Beijing, Hong Kong, Irkutsk, Kuala Lumpur, Manila, Perth |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/utils/Converter.java | ||
---|---|---|
3 | 3 |
import eu.dnetlib.domain.data.Repository; |
4 | 4 |
import eu.dnetlib.domain.data.RepositoryInterface; |
5 | 5 |
import org.json.JSONArray; |
6 |
import org.json.JSONException; |
|
6 | 7 |
import org.json.JSONObject; |
7 | 8 |
|
8 | 9 |
import java.io.BufferedReader; |
... | ... | |
15 | 16 |
|
16 | 17 |
public class Converter { |
17 | 18 |
|
18 |
public static Repository jsonToRepositoryObject(JSONObject jsonObject) { |
|
19 |
public static Repository jsonToRepositoryObject(JSONObject jsonObject) throws JSONException {
|
|
19 | 20 |
|
20 | 21 |
Repository repository = new Repository(); |
21 | 22 |
JSONObject datasource = (JSONObject) jsonObject.get("datasource"); |
... | ... | |
105 | 106 |
return Double.valueOf(number); |
106 | 107 |
} |
107 | 108 |
|
108 |
public static List<Repository> jsonToRepositoryList(JSONArray rs) { |
|
109 |
public static List<Repository> jsonToRepositoryList(JSONArray rs) throws JSONException {
|
|
109 | 110 |
|
110 | 111 |
List<Repository> resultSet = new ArrayList<>(); |
111 | 112 |
for(int i=0;i<rs.length();i++) |
... | ... | |
113 | 114 |
return resultSet; |
114 | 115 |
} |
115 | 116 |
|
116 |
public static RepositoryInterface jsonToRepositoryInterfaceObject(JSONObject jsonObject) { |
|
117 |
public static RepositoryInterface jsonToRepositoryInterfaceObject(JSONObject jsonObject) throws JSONException {
|
|
117 | 118 |
|
118 | 119 |
RepositoryInterface repositoryInterface = new RepositoryInterface(); |
119 | 120 |
|
... | ... | |
130 | 131 |
return repositoryInterface; |
131 | 132 |
} |
132 | 133 |
|
133 |
public static String repositoryObjectToJson(Repository repository) { |
|
134 |
public static String repositoryObjectToJson(Repository repository) throws JSONException {
|
|
134 | 135 |
|
135 | 136 |
JSONObject jsonObject = new JSONObject(); |
136 | 137 |
jsonObject.put("activationId",repository.getActivationId()); |
... | ... | |
177 | 178 |
return jsonObject.toString(); |
178 | 179 |
} |
179 | 180 |
|
180 |
public static String repositoryInterfaceObjectToJson(RepositoryInterface repositoryInterface) { |
|
181 |
public static String repositoryInterfaceObjectToJson(RepositoryInterface repositoryInterface) throws JSONException {
|
|
181 | 182 |
|
182 | 183 |
JSONObject jsonObject = new JSONObject(); |
183 | 184 |
|
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/main/Application.java | ||
---|---|---|
1 |
/* |
|
1 | 2 |
package eu.dnetlib.repo.manager.service.main; |
2 | 3 |
|
3 | 4 |
|
... | ... | |
15 | 16 |
SpringApplication.run(Application.class, args); |
16 | 17 |
} |
17 | 18 |
} |
19 |
*/ |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/controllers/ValidatorApi.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.service.controllers; |
|
2 |
|
|
3 |
import eu.dnetlib.domain.functionality.validator.JobForValidation; |
|
4 |
import eu.dnetlib.domain.functionality.validator.RuleSet; |
|
5 |
import org.json.JSONException; |
|
6 |
import org.springframework.http.MediaType; |
|
7 |
import org.springframework.web.bind.annotation.RequestBody; |
|
8 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
9 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
10 |
import org.springframework.web.bind.annotation.RestController; |
|
11 |
|
|
12 |
import java.util.List; |
|
13 |
|
|
14 |
|
|
15 |
@RestController |
|
16 |
@RequestMapping(value = "/validator") |
|
17 |
public interface ValidatorApi { |
|
18 |
|
|
19 |
@RequestMapping(value = "/submitJobForValidation",method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE ) |
|
20 |
void submitJobForValidation(@RequestBody JobForValidation jobForValidation); |
|
21 |
|
|
22 |
@RequestMapping(value = "/reSubmitJobForValidation/",method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE ) |
|
23 |
void reSubmitJobForValidation(@RequestBody String jobId) throws JSONException; |
|
24 |
|
|
25 |
@RequestMapping(value = "/getRuleSets" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) |
|
26 |
List<RuleSet> getRuleSets(); |
|
27 |
|
|
28 |
@RequestMapping(value = "/getSetsOfRepository/{url}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) |
|
29 |
List<String> getSetsOfRepository(String url); |
|
30 |
|
|
31 |
} |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/controllers/BrokerApiImpl.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.service.controllers; |
|
2 |
|
|
3 |
|
|
4 |
import com.fasterxml.jackson.databind.ObjectMapper; |
|
5 |
import com.google.gson.Gson; |
|
6 |
import eu.dnetlib.domain.data.Repository; |
|
7 |
import eu.dnetlib.repo.manager.service.shared.BrokerException; |
|
8 |
import eu.dnetlib.repo.manager.service.shared.Tuple; |
|
9 |
import eu.dnetlib.repo.manager.service.shared.broker.AdvQueryObject; |
|
10 |
import eu.dnetlib.repo.manager.service.shared.broker.BrowseEntry; |
|
11 |
import eu.dnetlib.repo.manager.service.shared.broker.DatasourcesBroker; |
|
12 |
import eu.dnetlib.repo.manager.service.shared.broker.EventsPage; |
|
13 |
import org.json.JSONException; |
|
14 |
import org.json.JSONObject; |
|
15 |
import org.springframework.beans.factory.annotation.Autowired; |
|
16 |
import org.springframework.beans.factory.annotation.Value; |
|
17 |
import org.springframework.core.ParameterizedTypeReference; |
|
18 |
import org.springframework.http.HttpEntity; |
|
19 |
import org.springframework.http.HttpMethod; |
|
20 |
import org.springframework.http.ResponseEntity; |
|
21 |
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; |
|
22 |
import org.springframework.stereotype.Component; |
|
23 |
import org.springframework.util.LinkedMultiValueMap; |
|
24 |
import org.springframework.util.MultiValueMap; |
|
25 |
import org.springframework.web.bind.annotation.PathVariable; |
|
26 |
import org.springframework.web.client.RestClientException; |
|
27 |
import org.springframework.web.client.RestTemplate; |
|
28 |
import org.springframework.web.util.UriComponentsBuilder; |
|
29 |
|
|
30 |
import java.util.*; |
|
31 |
|
|
32 |
@Component |
|
33 |
public class BrokerApiImpl implements BrokerApi { |
|
34 |
|
|
35 |
|
|
36 |
@Autowired |
|
37 |
private RepositoryApiImpl repoAPI; |
|
38 |
@Value("${services.broker.url}:${services.broker.port}/${services.broker.api}${services.broker.openaire}") |
|
39 |
private String openairePath; |
|
40 |
|
|
41 |
@Override |
|
42 |
public DatasourcesBroker getDatasourcesOfUser(String params) throws JSONException { |
|
43 |
JSONObject json_params = new JSONObject(params); |
|
44 |
DatasourcesBroker ret = new DatasourcesBroker(); |
|
45 |
|
|
46 |
String userEmail = json_params.getString("userEmail"); |
|
47 |
boolean includeShared = json_params.getBoolean("includeShared"); |
|
48 |
boolean includeByOthers = json_params.getBoolean("includeByOthers"); |
|
49 |
|
|
50 |
try { |
|
51 |
ret.setDatasourcesOfUser(getDatasourcesOfUserType(getRepositoriesOfUser(userEmail))); |
|
52 |
if (includeShared) { |
|
53 |
//TODO whatever nikonas was saying |
|
54 |
List<String> sharedDatasourceIds = new ArrayList<String>(); |
|
55 |
ret.setSharedDatasources(getDatasourcesOfUserType(getRepositoriesByIds(sharedDatasourceIds))); |
|
56 |
} |
|
57 |
|
|
58 |
if (includeByOthers) { |
|
59 |
ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(userEmail))); |
|
60 |
} |
|
61 |
} catch (BrokerException e) { |
|
62 |
e.printStackTrace(); |
|
63 |
} |
|
64 |
|
|
65 |
return ret; |
|
66 |
} |
|
67 |
|
|
68 |
@Override |
|
69 |
public List<BrowseEntry> getTopicsForDatasource(@PathVariable("datasourceName") String datasourceName) throws BrokerException { |
|
70 |
final String service = "/topicsForDatasource"; |
|
71 |
|
|
72 |
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service) |
|
73 |
.queryParam("ds", datasourceName); |
|
74 |
|
|
75 |
RestTemplate template = new RestTemplate(); |
|
76 |
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); |
|
77 |
ResponseEntity<List<BrowseEntry>> resp; |
|
78 |
try { |
|
79 |
resp = template.exchange( |
|
80 |
builder.build().encode().toUri(), |
|
81 |
HttpMethod.GET, |
|
82 |
null, |
|
83 |
new ParameterizedTypeReference<List<BrowseEntry>>() { |
|
84 |
}); |
|
85 |
} catch (RestClientException e) { |
|
86 |
throw new BrokerException(e); |
|
87 |
} |
|
88 |
|
|
89 |
return resp.getBody(); |
|
90 |
} |
|
91 |
|
|
92 |
@Override |
|
93 |
public EventsPage advancedShowEvents(String params) throws BrokerException, JSONException { |
|
94 |
JSONObject json_params = new JSONObject(params); |
|
95 |
|
|
96 |
long page = json_params.getLong("page"); |
|
97 |
long pagesize = json_params.getLong("pagesize"); |
|
98 |
|
|
99 |
JSONObject json_advQueryObject = json_params.getJSONObject("advQueryObject"); |
|
100 |
ObjectMapper obj = new ObjectMapper(); |
|
101 |
AdvQueryObject advQueryObject = new Gson().fromJson(json_advQueryObject.toString(),AdvQueryObject.class); |
|
102 |
|
|
103 |
|
|
104 |
final String service = "/events/{page}/{pageSize}"; |
|
105 |
|
|
106 |
Map<String, Long> uriParams = new HashMap<>(); |
|
107 |
uriParams.put("page", page); |
|
108 |
uriParams.put("pageSize", pagesize); |
|
109 |
|
|
110 |
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service); |
|
111 |
|
|
112 |
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); |
|
113 |
headers.add("Content-Type", "application/json"); |
|
114 |
|
|
115 |
advQueryObject.setPage(page); |
|
116 |
|
|
117 |
HttpEntity<AdvQueryObject> entity = new HttpEntity<>(advQueryObject, headers); |
|
118 |
|
|
119 |
RestTemplate template = new RestTemplate(); |
|
120 |
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); |
|
121 |
ResponseEntity<EventsPage> resp; |
|
122 |
try { |
|
123 |
resp = template.exchange( |
|
124 |
builder.buildAndExpand(uriParams).encode().toUri(), |
|
125 |
HttpMethod.POST, |
|
126 |
entity, |
|
127 |
new ParameterizedTypeReference<EventsPage>() { |
|
128 |
} |
|
129 |
); |
|
130 |
} catch (RestClientException e) { |
|
131 |
throw new BrokerException(e); |
|
132 |
} |
|
133 |
return resp.getBody(); |
|
134 |
|
|
135 |
|
|
136 |
} |
|
137 |
|
|
138 |
|
|
139 |
private List<Tuple<BrowseEntry, String>> getDatasourcesOfUserType(List<Repository> repositories) throws BrokerException { |
|
140 |
|
|
141 |
List<Tuple<BrowseEntry, String>> entries = new ArrayList<>(); |
|
142 |
for (Repository repo : repositories) { |
|
143 |
BrowseEntry temp = new BrowseEntry(); |
|
144 |
temp.setValue(repo.getOfficialName()); |
|
145 |
temp.setSize(new Long(0)); |
|
146 |
for (BrowseEntry e : getTopicsForDatasource(repo.getOfficialName())) { |
|
147 |
temp.setSize(temp.getSize() + e.getSize()); |
|
148 |
} |
|
149 |
Tuple<BrowseEntry, String> tup = new Tuple<>(temp, repo.getLogoUrl()); |
|
150 |
entries.add(tup); |
|
151 |
} |
|
152 |
|
|
153 |
// sort the collection by the second field of the tuple which is size |
|
154 |
Collections.sort(entries, new Comparator<Tuple<BrowseEntry, String>>() { |
|
155 |
@Override |
|
156 |
public int compare(Tuple<BrowseEntry, String> e1, Tuple<BrowseEntry, String> e2) { |
|
157 |
return (int) (e2.getFirst().getSize().longValue() - e1.getFirst().getSize().longValue()); |
|
158 |
} |
|
159 |
}); |
|
160 |
|
|
161 |
return entries; |
|
162 |
} |
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
private List<Repository> getRepositoriesOfUser(String userEmail) throws JSONException { |
|
167 |
|
|
168 |
int page = 1; |
|
169 |
int size = 10; |
|
170 |
List<Repository> rs = null; |
|
171 |
List<Repository> resultSet = new ArrayList<>(); |
|
172 |
|
|
173 |
while (true){ |
|
174 |
rs = repoAPI.getRepositoriesOfUser(userEmail, String.valueOf(page), String.valueOf(size)); |
|
175 |
if(rs.size() == 0) break; |
|
176 |
resultSet.addAll(rs); |
|
177 |
} |
|
178 |
return resultSet; |
|
179 |
} |
|
180 |
|
|
181 |
private List<Repository> getRepositoriesByIds(List<String> sharedDatasourceIds) { |
|
182 |
return null; |
|
183 |
} |
|
184 |
|
|
185 |
} |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/controllers/MonitorApi.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.service.controllers; |
|
2 |
|
|
3 |
import eu.dnetlib.domain.functionality.validator.StoredJob; |
|
4 |
import org.json.JSONException; |
|
5 |
import org.springframework.http.MediaType; |
|
6 |
import org.springframework.web.bind.annotation.RequestBody; |
|
7 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
8 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
9 |
import org.springframework.web.bind.annotation.RestController; |
|
10 |
|
|
11 |
import java.util.List; |
|
12 |
|
|
13 |
@RestController |
|
14 |
@RequestMapping(value = "/monitor") |
|
15 |
public interface MonitorApi { |
|
16 |
|
|
17 |
@RequestMapping(value = "/getJobsOfUser" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) |
|
18 |
List<StoredJob> getJobsOfUser(@RequestBody String params) throws JSONException; |
|
19 |
|
|
20 |
@RequestMapping(value = "/getJobsOfUser" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) |
|
21 |
int getJobsOfUserPerValidationStatus(@RequestBody String params) throws JSONException; |
|
22 |
|
|
23 |
@RequestMapping(value = "/getJobSummary" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) |
|
24 |
StoredJob getJobSummary(@RequestBody String params) throws JSONException; |
|
25 |
|
|
26 |
} |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/controllers/ValidatorApiImpl.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.service.controllers; |
|
2 |
|
|
3 |
import eu.dnetlib.api.functionality.ValidatorServiceException; |
|
4 |
import eu.dnetlib.domain.functionality.validator.StoredJob; |
|
5 |
import eu.dnetlib.repo.manager.service.utils.OaiTools; |
|
6 |
import gr.uoa.di.driver.util.ServiceLocator; |
|
7 |
import eu.dnetlib.domain.functionality.validator.JobForValidation; |
|
8 |
import eu.dnetlib.domain.functionality.validator.RuleSet; |
|
9 |
import eu.dnetlib.repo.manager.service.utils.Constants; |
|
10 |
|
|
11 |
import java.util.*; |
|
12 |
import java.util.concurrent.ConcurrentHashMap; |
|
13 |
import eu.dnetlib.api.functionality.ValidatorService; |
|
14 |
import org.json.JSONException; |
|
15 |
import org.json.JSONObject; |
|
16 |
import org.springframework.beans.factory.annotation.Autowired; |
|
17 |
import org.springframework.beans.factory.annotation.Value; |
|
18 |
import org.springframework.stereotype.Component; |
|
19 |
import org.springframework.web.bind.annotation.PathVariable; |
|
20 |
|
|
21 |
import javax.annotation.PostConstruct; |
|
22 |
|
|
23 |
@Component(value = "validationService") |
|
24 |
public class ValidatorApiImpl implements ValidatorApi{ |
|
25 |
|
|
26 |
@Autowired |
|
27 |
private MonitorApiImpl monitorApi; |
|
28 |
|
|
29 |
@Autowired |
|
30 |
private ServiceLocator<ValidatorService> validatorServiceLocator; |
|
31 |
|
|
32 |
private ValidatorService getValidationService() { |
|
33 |
return this.validatorServiceLocator.getService(); |
|
34 |
} |
|
35 |
|
|
36 |
public ServiceLocator<ValidatorService> getValidatorServiceLocator() { |
|
37 |
return validatorServiceLocator; |
|
38 |
} |
|
39 |
|
|
40 |
public void setValidatorServiceLocator(ServiceLocator<ValidatorService> validatorServiceLocator) { |
|
41 |
this.validatorServiceLocator = validatorServiceLocator; |
|
42 |
} |
|
43 |
|
Also available in: Unified diff
Configuration