Revision 50614
Added by Panagiotis Kanakakis about 6 years ago
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/utils/Converter.java | ||
---|---|---|
31 | 31 |
|
32 | 32 |
repository.setActivationId(datasource.get("activationId").toString()); |
33 | 33 |
repository.setAggregator(datasource.get("aggregator").toString()); |
34 |
repository.setCertificates(datasource.get("certificates").toString()); |
|
35 |
repository.setCitationGuidelineUrl(datasource.get("citationguidelineurl").toString()); |
|
36 |
repository.setCollectedFrom( datasource.get("collectedfrom").toString()); |
|
34 |
// repository.setCertificates(datasource.get("certificates").toString());
|
|
35 |
// repository.setCitationGuidelineUrl(datasource.get("citationguidelineurl").toString());
|
|
36 |
// repository.setCollectedFrom( datasource.get("collectedfrom").toString());
|
|
37 | 37 |
|
38 | 38 |
repository.setContactEmail(datasource.get("contactemail").toString()); |
39 | 39 |
if(repository.getContactEmail().equals("null")) |
40 | 40 |
repository.setContactEmail(""); |
41 | 41 |
|
42 |
repository.setDatabaseAccessRestriction(datasource.get("databaseaccessrestriction").toString()); |
|
43 |
repository.setDatabaseAccessType(datasource.get("databaseaccesstype").toString()); |
|
44 |
repository.setDataUploadRestriction(datasource.get("datauploadrestriction").toString()); |
|
45 |
repository.setDataUploadType(datasource.get("datauploadtype").toString()); |
|
42 |
// repository.setDatabaseAccessRestriction(datasource.get("databaseaccessrestriction").toString());
|
|
43 |
// repository.setDatabaseAccessType(datasource.get("databaseaccesstype").toString());
|
|
44 |
// repository.setDataUploadRestriction(datasource.get("datauploadrestriction").toString());
|
|
45 |
// repository.setDataUploadType(datasource.get("datauploadtype").toString());
|
|
46 | 46 |
repository.setDateOfCollection(convertStringToDate( datasource.get("dateofcollection").toString())); |
47 | 47 |
repository.setDateOfValidation(convertStringToDate( datasource.get("dateofvalidation").toString())); |
48 | 48 |
|
... | ... | |
69 | 69 |
|
70 | 70 |
repository.setLongitude(toDouble(datasource.get("longitude").toString())); |
71 | 71 |
//datasource.get("managed"); |
72 |
repository.setMissionStatementUrl(datasource.get("missionstatementurl").toString()); |
|
72 |
// repository.setMissionStatementUrl(datasource.get("missionstatementurl").toString());
|
|
73 | 73 |
repository.setNamespacePrefix(datasource.get("namespaceprefix").toString()); |
74 |
repository.setOdContentTypes(datasource.get("od_contenttypes").toString()); |
|
74 |
// repository.setOdContentTypes(datasource.get("od_contenttypes").toString());
|
|
75 | 75 |
repository.setOfficialName(datasource.get("officialname").toString()); |
76 | 76 |
if(repository.getOfficialName().equals("null")) |
77 | 77 |
repository.setOfficialName(""); |
78 | 78 |
|
79 |
repository.setPidSystems(datasource.get("pidsystems").toString()); |
|
79 |
// repository.setPidSystems(datasource.get("pidsystems").toString());
|
|
80 | 80 |
//datasource.get("platform"); |
81 |
repository.setProvenanceActionClass( datasource.get("provenanceaction").toString()); |
|
82 |
repository.setQualityManagementKind(datasource.get("qualitymanagementkind").toString()); |
|
81 |
// repository.setProvenanceActionClass( datasource.get("provenanceaction").toString());
|
|
82 |
// repository.setQualityManagementKind(datasource.get("qualitymanagementkind").toString());
|
|
83 | 83 |
repository.setRegisteredBy(datasource.get("registeredby").toString()); |
84 | 84 |
|
85 | 85 |
if(Objects.equals(repository.getRegisteredBy(),"null")) |
86 | 86 |
repository.setRegistered(true); |
87 | 87 |
|
88 |
repository.setReleaseEndDate(convertStringToDate(datasource.get("releaseenddate").toString())); |
|
89 |
repository.setReleaseStartDate(convertStringToDate(datasource.get("releasestartdate").toString())); |
|
90 |
repository.setServiceProvider(Boolean.valueOf(datasource.get("serviceprovider").toString())); |
|
88 |
// repository.setReleaseEndDate(convertStringToDate(datasource.get("releaseenddate").toString()));
|
|
89 |
// repository.setReleaseStartDate(convertStringToDate(datasource.get("releasestartdate").toString()));
|
|
90 |
// repository.setServiceProvider(Boolean.valueOf(datasource.get("serviceprovider").toString()));
|
|
91 | 91 |
//datasource.get("subjects"); |
92 | 92 |
Double timezone = toDouble(datasource.get("timezone").toString()); |
93 | 93 |
repository.setTimezone(timezone!=null?timezone:0.0); |
94 | 94 |
repository.setTypology(datasource.get("platform").toString()); |
95 |
repository.setVersioning(Boolean.valueOf(datasource.get("versioning").toString())); |
|
95 |
// repository.setVersioning(Boolean.valueOf(datasource.get("versioning").toString()));
|
|
96 | 96 |
repository.setWebsiteUrl(datasource.get("websiteurl").toString()); |
97 | 97 |
repository.setDatasourceClass(datasource.get("typology").toString()); |
98 | 98 |
|
... | ... | |
102 | 102 |
repository.setCountryCode(countryCode); |
103 | 103 |
|
104 | 104 |
|
105 |
String collectedFrom = datasource.get("collectedfrom").toString(); |
|
105 |
/* String collectedFrom = datasource.get("collectedfrom").toString();
|
|
106 | 106 |
//TODO check data consistency |
107 | 107 |
String type = "UNKNOWN"; |
108 | 108 |
if (collectedFrom.equalsIgnoreCase("openaire____::opendoar")) { |
... | ... | |
111 | 111 |
type = "re3data"; |
112 | 112 |
} else if (collectedFrom.equalsIgnoreCase("infrastruct_::openaire")) { |
113 | 113 |
type = "journal"; |
114 |
} |
|
114 |
}*/
|
|
115 | 115 |
|
116 |
repository.setDatasourceType(type); |
|
116 |
// repository.setDatasourceType(type);
|
|
117 | 117 |
|
118 | 118 |
|
119 | 119 |
return repository; |
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/utils/RequestFilter.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.service.utils; |
|
2 |
|
|
3 |
|
|
4 |
public class RequestFilter{ |
|
5 |
|
|
6 |
private String registeredby = ""; |
|
7 |
private String typology = ""; |
|
8 |
|
|
9 |
|
|
10 |
public RequestFilter() { |
|
11 |
|
|
12 |
} |
|
13 |
|
|
14 |
public String getTypology() { |
|
15 |
return typology; |
|
16 |
} |
|
17 |
|
|
18 |
public void setTypology(String typology) { |
|
19 |
this.typology = typology; |
|
20 |
} |
|
21 |
|
|
22 |
public String getRegisteredby() { |
|
23 |
return registeredby; |
|
24 |
} |
|
25 |
|
|
26 |
public void setRegisteredby(String registeredby) { |
|
27 |
this.registeredby = registeredby; |
|
28 |
} |
|
29 |
} |
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/controllers/BrokerApiImpl.java | ||
---|---|---|
132 | 132 |
} |
133 | 133 |
|
134 | 134 |
@Override |
135 |
public EventsPage advancedShowEvents(String params) throws BrokerException, JSONException ,IOException {
|
|
136 |
JSONObject json_params = new JSONObject(params); |
|
135 |
public EventsPage advancedShowEvents(String page,String size,AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException {
|
|
136 |
/*JSONObject json_params = new JSONObject(params);
|
|
137 | 137 |
|
138 | 138 |
String page = json_params.getString("page"); |
139 | 139 |
String pagesize = json_params.getString("pagesize"); |
140 | 140 |
String json_advQueryObject = json_params.getString("advQueryObject"); |
141 | 141 |
|
142 | 142 |
ObjectMapper mapper = new ObjectMapper(); |
143 |
AdvQueryObject advQueryObject = mapper.readValue(json_advQueryObject, AdvQueryObject.class); |
|
143 |
AdvQueryObject advQueryObject = mapper.readValue(json_advQueryObject, AdvQueryObject.class);*/
|
|
144 | 144 |
|
145 | 145 |
final String service = "/events/{page}/{pageSize}"; |
146 | 146 |
|
147 | 147 |
Map<String, Long> uriParams = new HashMap<>(); |
148 | 148 |
uriParams.put("page", Long.parseLong(page)); |
149 |
uriParams.put("pageSize", Long.parseLong(pagesize));
|
|
149 |
uriParams.put("pageSize", Long.parseLong(size)); |
|
150 | 150 |
|
151 | 151 |
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service); |
152 | 152 |
|
153 | 153 |
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); |
154 |
headers.add("Content-Type", "application/json"); |
|
155 |
|
|
156 | 154 |
advQueryObject.setPage(Long.parseLong(page)); |
157 |
|
|
158 |
HttpEntity<AdvQueryObject> entity = new HttpEntity<>(advQueryObject, headers); |
|
159 |
|
|
155 |
HttpEntity<AdvQueryObject> entity = new HttpEntity<>(advQueryObject, httpHeaders); |
|
160 | 156 |
ResponseEntity<EventsPage> resp; |
161 | 157 |
try { |
162 | 158 |
resp = restTemplate.exchange( |
... | ... | |
223 | 219 |
} |
224 | 220 |
|
225 | 221 |
@Override |
226 |
public EventsPage showEvents(String params) throws BrokerException, JSONException {
|
|
222 |
public EventsPage showEvents(String datasourceName,String topic,String page) throws BrokerException, JSONException {
|
|
227 | 223 |
|
228 |
JSONObject json_params = new JSONObject(params); |
|
224 |
/*JSONObject json_params = new JSONObject(params);
|
|
229 | 225 |
|
230 | 226 |
String datasourceName = json_params.getString("datasourceName"); |
231 | 227 |
String topic = json_params.getString("topic"); |
232 |
String page = json_params.getString("page"); |
|
228 |
String page = json_params.getString("page");*/
|
|
233 | 229 |
|
234 | 230 |
final String service = "/showEvents"; |
235 | 231 |
|
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApi.java | ||
---|---|---|
102 | 102 |
@RequestMapping(value = "/updateEnglishName", method = RequestMethod.POST, |
103 | 103 |
produces = MediaType.APPLICATION_JSON_VALUE) |
104 | 104 |
@ResponseBody |
105 |
String updateEnglishName(String id, String englishName); |
|
105 |
String updateEnglishName(String id,String officialName, String englishName);
|
|
106 | 106 |
|
107 | 107 |
@RequestMapping(value = "/updateLatitude", method = RequestMethod.POST, |
108 | 108 |
produces = MediaType.APPLICATION_JSON_VALUE) |
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApiImpl.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.repo.manager.service.controllers; |
2 | 2 |
|
3 |
import com.fasterxml.jackson.core.JsonProcessingException; |
|
3 | 4 |
import com.fasterxml.jackson.databind.DeserializationFeature; |
4 | 5 |
import com.fasterxml.jackson.databind.ObjectMapper; |
5 | 6 |
import eu.dnetlib.domain.data.Repository; |
6 | 7 |
import eu.dnetlib.domain.data.RepositoryInterface; |
7 | 8 |
import eu.dnetlib.domain.enabling.Vocabulary; |
8 | 9 |
import eu.dnetlib.repo.manager.service.utils.Converter; |
10 |
import eu.dnetlib.repo.manager.service.utils.RequestFilter; |
|
9 | 11 |
import eu.dnetlib.repo.manager.shared.*; |
10 | 12 |
import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader; |
11 | 13 |
import org.apache.commons.codec.digest.DigestUtils; |
... | ... | |
16 | 18 |
import org.springframework.beans.factory.annotation.Autowired; |
17 | 19 |
import org.springframework.beans.factory.annotation.Value; |
18 | 20 |
import org.springframework.core.ParameterizedTypeReference; |
19 |
import org.springframework.http.HttpEntity; |
|
20 |
import org.springframework.http.HttpHeaders; |
|
21 |
import org.springframework.http.HttpMethod; |
|
22 |
import org.springframework.http.ResponseEntity; |
|
21 |
import org.springframework.http.*; |
|
23 | 22 |
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; |
24 | 23 |
import org.springframework.stereotype.Component; |
25 | 24 |
import org.springframework.web.bind.annotation.PathVariable; |
... | ... | |
31 | 30 |
import org.springframework.web.util.UriComponentsBuilder; |
32 | 31 |
|
33 | 32 |
import javax.annotation.PostConstruct; |
34 |
import javax.ws.rs.QueryParam; |
|
35 | 33 |
import java.sql.Timestamp; |
36 | 34 |
import java.text.Normalizer; |
37 | 35 |
import java.util.*; |
... | ... | |
222 | 220 |
|
223 | 221 |
LOGGER.debug("Retreiving repositories of user : " + userEmail ); |
224 | 222 |
UriComponents uriComponents = UriComponentsBuilder |
225 |
.fromHttpUrl(baseAddress + "/ds/search/registeredby/")
|
|
223 |
.fromHttpUrl(baseAddress + "/ds/search/") |
|
226 | 224 |
.path("/{page}/{size}/") |
227 |
.queryParam("registeredBy", userEmail) |
|
225 |
.queryParam("requestSortBy","id") |
|
226 |
.queryParam("order","ASCENDING") |
|
228 | 227 |
.build().expand(page, size).encode(); |
229 | 228 |
|
230 |
String rs = restTemplate.getForObject(uriComponents.toUri(), String.class); |
|
229 |
RequestFilter requestFilter = new RequestFilter(); |
|
230 |
requestFilter.setRegisteredby(userEmail); |
|
231 |
|
|
232 |
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class); |
|
233 |
|
|
231 | 234 |
List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs)); |
232 | 235 |
for (Repository r : repos) |
233 | 236 |
this.getRepositoryInfo(r); |
... | ... | |
362 | 365 |
|
363 | 366 |
private void updateRepository(Repository repository) { |
364 | 367 |
this.updateRegisteredByValue(repository.getId(),repository.getRegisteredBy()); |
365 |
this.updateEnglishName(repository.getId(),repository.getEnglishName()); |
|
368 |
this.updateEnglishName(repository.getId(),repository.getOfficialName(),repository.getEnglishName());
|
|
366 | 369 |
this.updateLogoUrl(repository.getId(),repository.getLogoUrl()); |
367 | 370 |
this.updateTimezone(repository.getId(), String.valueOf(repository.getTimezone())); |
368 | 371 |
//TODO update datasource type |
... | ... | |
575 | 578 |
|
576 | 579 |
@Override |
577 | 580 |
public String updateEnglishName(@RequestParam(value = "id") String id, |
581 |
@RequestParam(value = "officialName") String officialName, |
|
578 | 582 |
@RequestParam(value = "englishname") String englishName) { |
579 | 583 |
|
580 | 584 |
UriComponents uriComponents = UriComponentsBuilder |
581 |
.fromHttpUrl(baseAddress + "/ds/englishname/")
|
|
585 |
.fromHttpUrl(baseAddress + "/ds/name/") |
|
582 | 586 |
.queryParam("dsId",id) |
587 |
.queryParam("officialname",officialName) |
|
583 | 588 |
.queryParam("englishname",englishName) |
584 | 589 |
.build().encode(); |
585 | 590 |
return restTemplate.postForObject(uriComponents.toUri(), null,String.class); |
... | ... | |
667 | 672 |
} |
668 | 673 |
|
669 | 674 |
@Override |
670 |
public List<String> getUrlsOfUserRepos(@PathVariable("user_email") String user_email,
|
|
675 |
public List<String> getUrlsOfUserRepos(@PathVariable("user_email") String userEmail,
|
|
671 | 676 |
@PathVariable("page") String page, |
672 | 677 |
@PathVariable("size") String size) throws JSONException { |
673 | 678 |
UriComponents uriComponents = UriComponentsBuilder |
674 | 679 |
.fromHttpUrl(baseAddress + "/api/baseurl/") |
675 | 680 |
.path("/{page}/{size}") |
676 |
.queryParam("userEmail",user_email) |
|
677 | 681 |
.build().expand(page,size).encode(); |
678 |
return Arrays.asList(restTemplate.getForObject(uriComponents.toUri(), String[].class)); |
|
682 |
|
|
683 |
|
|
684 |
RequestFilter requestFilter = new RequestFilter(); |
|
685 |
requestFilter.setRegisteredby(userEmail); |
|
686 |
return Arrays.asList(restTemplate.postForObject(uriComponents.toUri(),requestFilter, String[].class)); |
|
679 | 687 |
} |
680 | 688 |
|
681 | 689 |
@Override |
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/controllers/BrokerApi.java | ||
---|---|---|
4 | 4 |
import eu.dnetlib.repo.manager.shared.Term; |
5 | 5 |
import eu.dnetlib.repo.manager.shared.broker.*; |
6 | 6 |
import io.swagger.annotations.Api; |
7 |
import io.swagger.annotations.ApiParam; |
|
7 | 8 |
import org.json.JSONException; |
8 | 9 |
import org.springframework.http.MediaType; |
9 | 10 |
import org.springframework.web.bind.annotation.*; |
... | ... | |
23 | 24 |
@RequestMapping(value = "/getTopicsForDatasource/{datasourceName}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) |
24 | 25 |
List<BrowseEntry> getTopicsForDatasource(String datasourceName) throws BrokerException; |
25 | 26 |
|
26 |
@RequestMapping(value = "/advancedShowEvents" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) |
|
27 |
EventsPage advancedShowEvents(@RequestBody String params) throws BrokerException, JSONException ,IOException; |
|
27 |
@RequestMapping(value = "/advancedShowEvents/{page}/{size}" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) |
|
28 |
EventsPage advancedShowEvents(@PathVariable("page") String page, |
|
29 |
@PathVariable("size") String size, |
|
30 |
@RequestBody AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException; |
|
28 | 31 |
|
29 |
@RequestMapping(value = "/showEvents" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) |
|
30 |
EventsPage showEvents(@RequestBody String params) throws BrokerException, JSONException; |
|
32 |
@RequestMapping(value = "/showEvents/{datasourceName}/{topic}/{page}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) |
|
33 |
EventsPage showEvents(@PathVariable("datasourceName") String datasourceName, |
|
34 |
@PathVariable("topic") String topic, |
|
35 |
@PathVariable("page") String page) throws BrokerException, JSONException; |
|
31 | 36 |
|
32 | 37 |
@RequestMapping(value = "/getSimpleSubscriptionsOfUser/{userEmail}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) |
33 | 38 |
@ResponseBody |
modules/uoa-repository-manager-service/trunk/src/main/webapp/WEB-INF/applicationContext.xml | ||
---|---|---|
30 | 30 |
<import resource="classpath*:/gr/uoa/di/driver/app/springContext-commons.xml"/> |
31 | 31 |
<import resource="classpath*:/gr/uoa/di/driver/app/springContext-registrator.xml"/> |
32 | 32 |
|
33 |
<import resource="classpath*:/eu/dnetlib/repos/springContext-repos-dms-cached.xml"/>
|
|
33 |
<!--<import resource="classpath*:/eu/dnetlib/repos/springContext-repos-dms-cached.xml"/>-->
|
|
34 | 34 |
<context:property-placeholder location="classpath*:/eu/**/application.properties" /> |
35 | 35 |
|
36 | 36 |
<bean class="eu.dnetlib.repo.manager.service.config.CascadingPropertyLoader" id="propertyLoader"> |
modules/uoa-repository-manager-service/trunk/src/main/webapp/WEB-INF/web.xml | ||
---|---|---|
5 | 5 |
http://xmlns.jcp.org/xml/ns/javaee " |
6 | 6 |
version="3.1"> |
7 | 7 |
|
8 |
<filter> |
|
9 |
<filter-name>CorsFilter</filter-name> |
|
10 |
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class> |
|
11 |
<init-param> |
|
12 |
<param-name>cors.allowed.origins</param-name> |
|
13 |
<param-value>*</param-value> |
|
14 |
</init-param> |
|
15 |
<init-param> |
|
16 |
<param-name>cors.allowed.headers</param-name> |
|
17 |
<param-value>Content-Type,X-Requested-With,accept,authorization,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value> |
|
18 |
</init-param> |
|
19 |
<init-param> |
|
20 |
<param-name>cors.allowed.methods</param-name> |
|
21 |
<param-value>GET, POST, PUT, DELETE, OPTIONS, HEAD</param-value> |
|
22 |
</init-param> |
|
23 |
</filter> |
|
24 |
|
|
25 |
<filter-mapping> |
|
26 |
<filter-name>CorsFilter</filter-name> |
|
27 |
<url-pattern>/*</url-pattern> |
|
28 |
</filter-mapping> |
|
29 |
|
|
8 | 30 |
<context-param> |
9 | 31 |
<param-name>log4jConfigLocation</param-name> |
10 | 32 |
<param-value>/WEB-INF/log4j.properties</param-value> |
modules/uoa-repository-manager-service/trunk/pom.xml | ||
---|---|---|
230 | 230 |
<version>9.1-901.jdbc3</version> |
231 | 231 |
</dependency> |
232 | 232 |
|
233 |
<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-catalina --> |
|
234 |
<dependency> |
|
235 |
<groupId>org.apache.tomcat</groupId> |
|
236 |
<artifactId>tomcat-catalina</artifactId> |
|
237 |
<version>LATEST</version> |
|
238 |
</dependency> |
|
239 |
|
|
240 |
|
|
233 | 241 |
<!--<dependency> |
234 | 242 |
<groupId>org.mitre</groupId> |
235 | 243 |
<artifactId>openid-connect-client</artifactId> |
Also available in: Unified diff
1. New rest api
2. Cors filter on web.xml
3. Remove aai