- Update the "RepositoryServiceImpl.getCompatibilityClasses()" method to recognise additional "CRIS" modes.
- Catch exceptions thrown in "RepositoryServiceImpl.searchApi()". - Code optimization. - Update dependencies.
This commit is contained in:
parent
c836de5761
commit
cb458553f0
6
pom.xml
6
pom.xml
|
@ -184,7 +184,7 @@
|
|||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.15.1</version>
|
||||
<version>2.16.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -204,7 +204,7 @@
|
|||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-client</artifactId>
|
||||
<version>2.41</version>
|
||||
<version>2.42</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
@ -231,7 +231,7 @@
|
|||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>42.7.2</version>
|
||||
<version>42.7.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
|
@ -686,19 +686,20 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
public Map<String, String> getCompatibilityClasses(String mode) {
|
||||
|
||||
logger.debug("Getting compatibility classes for mode: {}", mode);
|
||||
String lowercaseMode = mode.toLowerCase();
|
||||
Map<String, String> retMap = new HashMap<>();
|
||||
|
||||
Map<String, String> compatibilityClasses = this.getVocabulary("dnet:compatibilityLevel").getAsMap();
|
||||
boolean foundData = false;
|
||||
for (Map.Entry<String, String> entry : compatibilityClasses.entrySet()) {
|
||||
if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_ALL))
|
||||
if (lowercaseMode.equals(Constants.REPOSITORY_MODE_ALL))
|
||||
return compatibilityClasses;
|
||||
else if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_RE3DATA)) {
|
||||
else if (lowercaseMode.equals(Constants.REPOSITORY_MODE_RE3DATA)) {
|
||||
if (ValidatorServiceImpl.OPENAIRE_DATA_REGEX.matcher(entry.getKey()).matches()) {
|
||||
retMap.put(entry.getKey(), entry.getValue());
|
||||
foundData = true;
|
||||
}
|
||||
} else if (mode.equalsIgnoreCase("cris")) {
|
||||
} else if (lowercaseMode.startsWith("cris")) { // Future proofing for inconsistent CRIS modes.
|
||||
if (entry.getKey().contains("openaire-cris")) {
|
||||
retMap.put(entry.getKey(), entry.getValue());
|
||||
foundData = true;
|
||||
|
@ -710,7 +711,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
}
|
||||
|
||||
//TODO TO BE REMOVED WHEN VOCABULARIES ARE UPDATED
|
||||
if ((mode.equalsIgnoreCase("repository") || mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_RE3DATA)) && !foundData)
|
||||
if ((lowercaseMode.equals("repository") || lowercaseMode.equals(Constants.REPOSITORY_MODE_RE3DATA)) && !foundData)
|
||||
retMap.put("openaire2.0_data", "OpenAIRE Data (funded, referenced datasets)");
|
||||
|
||||
return retMap;
|
||||
|
@ -934,7 +935,12 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
private <T> Paging<T> searchApi(UriComponents uriComponents, RequestFilter requestFilter, Class<T> clazz) {
|
||||
Paging<T> repositories = new Paging<>();
|
||||
ResponseEntity<Map> rs;
|
||||
rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, new HttpEntity<>(requestFilter), Map.class);
|
||||
try {
|
||||
rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, new HttpEntity<>(requestFilter), Map.class);
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
throw e;
|
||||
}
|
||||
if (!rs.getStatusCode().is2xxSuccessful()) {
|
||||
logger.error("Api call not successful. Code: {} | Body: {}", rs.getStatusCode(), rs.getBody());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue