Fixed various issues with the new externalUrls restTemplate
This commit is contained in:
parent
c02157be8c
commit
ae03077795
|
@ -190,11 +190,10 @@ public class RemoteFetcher {
|
|||
if (funderId.toCharArray()[0] == ':') {
|
||||
funderId = externalUrlCriteria.getFunderId();
|
||||
}
|
||||
try {
|
||||
funderId = URLEncoder.encode(funderId, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
/*
|
||||
try { funderId = URLEncoder.encode(funderId, "UTF-8"); } catch
|
||||
(UnsupportedEncodingException e) { logger.error(e.getMessage(), e); }
|
||||
*/
|
||||
completedPath = completedPath.replace("{funderId}", funderId);
|
||||
}
|
||||
if (externalUrlCriteria.getPage() != null) {
|
||||
|
@ -260,12 +259,12 @@ public class RemoteFetcher {
|
|||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
HttpEntity<String> entity;
|
||||
ResponseEntity response;
|
||||
ResponseEntity<String> response;
|
||||
/*
|
||||
URL url = new URL(urlString.replaceAll(" ", "%20"));
|
||||
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
* URL url = new URL(urlString.replaceAll(" ", "%20"));
|
||||
*
|
||||
* HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
* con.setRequestMethod("GET");
|
||||
*/
|
||||
if (contentType != null && !contentType.isEmpty()) {
|
||||
headers.setAccept(Collections.singletonList(MediaType.valueOf(contentType)));
|
||||
|
@ -273,11 +272,7 @@ public class RemoteFetcher {
|
|||
|
||||
entity = new HttpEntity<>("parameters", headers);
|
||||
|
||||
if (contentType.contains("json")) {
|
||||
response = restTemplate.exchange(urlString, HttpMethod.GET, entity, Object.class);
|
||||
} else {
|
||||
response = restTemplate.exchange(urlString, HttpMethod.GET, entity, String.class);
|
||||
}
|
||||
response = restTemplate.exchange(urlString, HttpMethod.GET, entity, String.class);
|
||||
if (response.getStatusCode() == HttpStatus.OK) { // success
|
||||
//do here all the parsing
|
||||
Results results = new Results();
|
||||
|
@ -387,7 +382,7 @@ public class RemoteFetcher {
|
|||
Class<?> aClass = Class.forName(jsonDataPath.getParseClass());
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(aClass);
|
||||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
||||
StringReader stringReader = new StringReader(response.getBody().toString());
|
||||
StringReader stringReader = new StringReader(response.getBody());
|
||||
Object data = unmarshaller.unmarshal(stringReader);
|
||||
Method reader = null;
|
||||
if (jsonDataPath.getParseField() != null && !jsonDataPath.getParseField().isEmpty()) {
|
||||
|
|
|
@ -149,8 +149,8 @@
|
|||
<key>openaire</key>
|
||||
<label>OpenAIRE</label>
|
||||
<ordinal>1</ordinal>
|
||||
<url>https://services.openaire.eu/search/v2/api/resources?query=((oaftype%20exact%20project)%20and%20((projectcode_nt%20exact%20%22{like}%22)or({like}))){funderQuery}&page={page}&size={pageSize}&format=json</url>
|
||||
<funderQuery>&fq=(funder%20exact%20%22{funderId}%22)</funderQuery>
|
||||
<url>https://services.openaire.eu/search/v2/api/resources?query=((oaftype exact project) and ((projectcode_nt exact "{like}")or({like}))){funderQuery}&page={page}&size={pageSize}&format=json</url>
|
||||
<funderQuery>&fq=(funder exact "{funderId}")</funderQuery>
|
||||
<firstPage>0</firstPage>
|
||||
<contenttype>application/json; charset=utf-8</contenttype>
|
||||
<data>
|
||||
|
@ -228,7 +228,7 @@
|
|||
<label>OpenAIRE</label>
|
||||
<ordinal>1</ordinal>
|
||||
<type>External</type>
|
||||
<url>https://services.openaire.eu/search/v2/api/resources?query=((oaftype%20exact%20project)%20and%20((projectcode_nt%20exact%20%22*%22)or(*)))&fq=(funder%20exact%20{funderId})&page={page}&size={pageSize}&format=json</url>
|
||||
<url>https://services.openaire.eu/search/v2/api/resources?query=((oaftype exact project) and ((projectcode_nt exact "*")or(*)))&fq=(funder exact {funderId})&page={page}&size={pageSize}&format=json</url>
|
||||
<firstPage>0</firstPage>
|
||||
<contenttype>application/json; charset=utf-8</contenttype>
|
||||
<data>
|
||||
|
@ -501,7 +501,7 @@
|
|||
<label>OpenAIRE</label>
|
||||
<ordinal>1</ordinal>
|
||||
<type>External</type>
|
||||
<url>https://services.openaire.eu/search/v2/api/datasources?q={like}&fq=datasourcetypeuiname%20exact%20%22Data%20Repository%22&page={page}&size={pageSize}&format=json</url>
|
||||
<url>https://services.openaire.eu/search/v2/api/datasources?q={like}&fq=datasourcetypeuiname exact "Data Repository"&page={page}&size={pageSize}&format=json</url>
|
||||
<firstPage>0</firstPage>
|
||||
<contenttype>application/json;charset=UTF-8</contenttype>
|
||||
<data>
|
||||
|
@ -519,7 +519,7 @@
|
|||
<label>OpenAIRE Alternative</label>
|
||||
<ordinal>1</ordinal>
|
||||
<type>External</type>
|
||||
<url>https://services.openaire.eu/search/v2/api/resources?query=oaftype%20exact%20datasource%20and%20{like}&page={page}&size={pageSize}&format=json</url>
|
||||
<url>https://services.openaire.eu/search/v2/api/resources?query=oaftype exact datasource and {like}&page={page}&size={pageSize}&format=json</url>
|
||||
<firstPage>0</firstPage>
|
||||
<contenttype>application/json;charset=UTF-8</contenttype>
|
||||
<data>
|
||||
|
|
|
@ -58,8 +58,8 @@
|
|||
<key>openAIRE</key>
|
||||
<label>OpenAIRE</label>
|
||||
<ordinal>1</ordinal>
|
||||
<url>https://services.openaire.eu/search/v2/api/resources?query=((oaftype%20exact%20project)%20and%20((projectcode_nt%20exact%20%22{like}%22)or({like}))){funderQuery}&page={page}&size={pageSize}&format=json</url>
|
||||
<funderQuery>&fq=(funder%20exact%20%22{funderId}%22)</funderQuery>
|
||||
<url>https://services.openaire.eu/search/v2/api/resources?query=((oaftype exact project) and ((projectcode_nt exact "{like}")or({like}))){funderQuery}&page={page}&size={pageSize}&format=json</url>
|
||||
<funderQuery>&fq=(funder exact "{funderId}")</funderQuery>
|
||||
<firstPage>0</firstPage>
|
||||
<contenttype>application/json; charset=utf-8</contenttype>
|
||||
<data>
|
||||
|
|
|
@ -61,8 +61,8 @@
|
|||
<key>openAIRE</key>
|
||||
<label>OpenAIRE</label>
|
||||
<ordinal>1</ordinal>
|
||||
<url>https://services.openaire.eu/search/v2/api/resources?query=((oaftype%20exact%20project)%20and%20((projectcode_nt%20exact%20%22{like}%22)or({like}))){funderQuery}&page={page}&size={pageSize}&format=json</url>
|
||||
<funderQuery>&fq=(funder%20exact%20%22{funderId}%22)</funderQuery>
|
||||
<url>https://services.openaire.eu/search/v2/api/resources?query=((oaftype exact project) and ((projectcode_nt exact "{like}")or({like}))){funderQuery}&page={page}&size={pageSize}&format=json</url>
|
||||
<funderQuery>&fq=(funder exact "{funderId}")</funderQuery>
|
||||
<firstPage>0</firstPage>
|
||||
<contenttype>application/json; charset=utf-8</contenttype>
|
||||
<data>
|
||||
|
|
Loading…
Reference in New Issue