Resolve tickets 9114 and 9031 #12

Merged
lsmyrnaios merged 10 commits from develop into master 2024-04-04 15:33:10 +02:00
12 changed files with 74 additions and 136 deletions

87
pom.xml
View File

@ -6,7 +6,8 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.17</version>
<version>2.7.18</version>
<relativePath></relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -16,7 +17,7 @@
<packaging>jar</packaging>
<properties>
<spring.boot.version>2.7.17</spring.boot.version>
<spring.boot.version>2.7.18</spring.boot.version>
</properties>
<dependencies>
@ -67,6 +68,24 @@
<version>${spring.boot.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>${spring.boot.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>${spring.boot.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
@ -74,24 +93,25 @@
<version>2.2.224</version>
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>9.4.0</version>
</dependency>
<dependency>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>dnet-exporter-api</artifactId>
<version>[3.3.3-SNAPSHOT, )</version>
<artifactId>dnet-exporter-model</artifactId>
<version>[3.5.1, )</version>
<exclusions>
<exclusion>
<groupId>eu.dnetlib</groupId>
<artifactId>dnet-index-solr-common</artifactId>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-common</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/io.micrometer/micrometer-registry-prometheus -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.12.4</version>
</dependency>
<dependency>
<groupId>eu.dnetlib</groupId>
<artifactId>uoa-clients</artifactId>
@ -133,13 +153,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>eu.dnetlib</groupId>
<artifactId>dnet-openaire-usage-stats-sushilite-r5</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/openaire-usage-stats-sushilite-r5-1.0.0.jar</systemPath>
</dependency>
<dependency>
<groupId>eu.dnetlib</groupId>
<artifactId>dnet-openaire-usage-stats-sushilite</artifactId>
@ -161,6 +174,7 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
@ -170,7 +184,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</dependency>
<dependency>
@ -190,7 +204,7 @@
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.41</version>
<version>2.42</version>
</dependency>
@ -204,7 +218,7 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20231013</version>
<version>20240303</version>
</dependency>
<dependency>
@ -213,27 +227,11 @@
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webmvc-core</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-security</artifactId>
<version>1.7.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.6.0</version>
<version>42.7.3</version>
</dependency>
<dependency>
@ -410,6 +408,15 @@
</build>
<repositories>
<repository>
<id>central</id>
<name>Maven Central</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>dnet45-bootstrap-snapshot</id>
<name>D-Net 45 Bootstrap Snapshot</name>
@ -464,6 +471,8 @@
<enabled>false</enabled>
</releases>
</repository>
<!-- Use this when testing local JARs. -->
<!--<repository>
<id>libs</id>
<url>file:///${project.basedir}/libs</url>

View File

@ -1,6 +1,6 @@
package eu.dnetlib.repo.manager.controllers;
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
import eu.dnetlib.repo.manager.domain.BrokerSummary;
import eu.dnetlib.repo.manager.domain.CollectionMonitorSummary;
import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo;

View File

@ -1,7 +1,7 @@
package eu.dnetlib.repo.manager.controllers;
import eu.dnetlib.domain.data.PiwikInfo;
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
import eu.dnetlib.repo.manager.domain.*;
import eu.dnetlib.repo.manager.domain.dto.RepositoryTerms;
import eu.dnetlib.repo.manager.domain.dto.User;
@ -9,7 +9,6 @@ import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
import eu.dnetlib.repo.manager.service.AggregationService;
import eu.dnetlib.repo.manager.service.PiWikService;
import eu.dnetlib.repo.manager.service.PiWikServiceImpl;
import eu.dnetlib.repo.manager.service.RepositoryService;
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
import eu.dnetlib.repo.manager.utils.JsonUtils;

View File

@ -1,29 +0,0 @@
package eu.dnetlib.repo.manager.domain;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import java.util.List;
@JsonAutoDetect
public class AggregationHistoryResponse extends Response {
private List<AggregationInfo> aggregationInfo;
public AggregationHistoryResponse() {
// no-arg constructor
}
public AggregationHistoryResponse(final List<AggregationInfo> aggregationInfo) {
super();
this.aggregationInfo = aggregationInfo;
}
public List<AggregationInfo> getAggregationInfo() {
return aggregationInfo;
}
public void setAggregationInfo(final List<AggregationInfo> aggregationInfo) {
this.aggregationInfo = aggregationInfo;
}
}

View File

@ -1,8 +0,0 @@
package eu.dnetlib.repo.manager.domain;
// TODO: this class must be replaced by common dnet class (CollectionInfo / TransformationInfo / AggregationInfo)
public class AggregationInfo extends eu.dnetlib.enabling.datasources.common.AggregationInfo {
public AggregationInfo() {
}
}

View File

@ -1,6 +1,6 @@
package eu.dnetlib.repo.manager.domain;
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
import java.util.List;

View File

@ -1,6 +1,6 @@
package eu.dnetlib.repo.manager.service;
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
import org.json.JSONException;
import java.util.List;

View File

@ -1,7 +1,7 @@
package eu.dnetlib.repo.manager.service;
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
import eu.dnetlib.repo.manager.domain.AggregationHistoryResponse;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationHistoryResponseV2;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@ -41,7 +41,7 @@ public class AggregationServiceImpl implements AggregationService {
logger.debug("Retrieving aggregations for repository with id : " + id);
UriComponents uriComponents = getAggregationHistory(id);
AggregationHistoryResponse rs = restTemplate.getForObject(uriComponents.toUri(), AggregationHistoryResponse.class);
AggregationHistoryResponseV2 rs = restTemplate.getForObject(uriComponents.toUri(), AggregationHistoryResponseV2.class);
return rs != null ? (List<T>) rs.getAggregationInfo() : null;
}
@ -73,7 +73,7 @@ public class AggregationServiceImpl implements AggregationService {
private UriComponents getAggregationHistory(String repoId) {
return UriComponentsBuilder
.fromHttpUrl(baseAddress + "/ds/aggregationhistory/")
.fromHttpUrl(baseAddress + "/dsm/2.0/aggregationhistory/")
.path(repoId)
.build().expand(repoId).encode();
}

View File

@ -1,6 +1,6 @@
package eu.dnetlib.repo.manager.service;
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
import eu.dnetlib.openaire.exporter.model.dsm.AggregationInfo;
import eu.dnetlib.repo.manager.domain.MetricsNumbers;
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo;
@ -49,7 +49,7 @@ public class DashboardServiceImpl implements DashboardService {
repositorySummaryInfo.setRepositoryName(repoOfficialName);
repositorySummaryInfo.setLogoURL(repository.getLogoUrl());
//TODO getRepositoryAggregations returns only the 20 more recent items. Is it positive that we will find an indexed version there?
//TODO getRepositoryAggregations returns only the 20 more recent items. Is it possible that we will find an indexed version there?
boolean isIndexedVersionFound = false;
long start = System.currentTimeMillis();
List<AggregationInfo> aggregationInfoList = aggregationService.getRepositoryAggregations(repoId, 0, 20);

View File

@ -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;
@ -863,6 +864,8 @@ public class RepositoryServiceImpl implements RepositoryService {
new ParameterizedTypeReference<MetricsNumbers>() {
});
// TODO - the project "usagestats" returns "200-OK" even for an invalid datasourceID.. Report this to the person who manages usage-stats.
return resp.getBody();
}
@ -932,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;
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());
}

View File

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:annotation-config/>
<context:component-scan base-package="eu.dnetlib.repo.manager.service.*"/>
<bean class="eu.dnetlib.repo.manager.config.CascadingPropertyLoader"
id="propertyLoader">
<property name="order" value="2"/>
<property name="properties">
<bean class="eu.dnetlib.conf.WebappContextProperyFactory">
<property name="propertyFetcher">
<bean class="eu.dnetlib.conf.PropertyFetcher"/>
</property>
</bean>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="locations">
<list>
<value>classpath*:/gr/**/springContext-*.properties</value>
<value>classpath*:/eu/**/springContext-*.properties</value>
<value>classpath*:/application.properties</value>
<value>classpath*:email-texts.properties</value>
<!-- <value>classpath*:dnet-site-wizard.properties</value>-->
<!-- <value>classpath*:dnet-site-override.properties</value>-->
<!-- <value>classpath*:dnet-wizard.properties</value>-->
<!-- <value>classpath*:dnet-override.properties</value>-->
<!-- <value>classpath*:dnet-validator-wizard.properties</value>-->
<!-- <value>classpath*:dnet-validator-override.properties</value>-->
<!-- <value>classpath*:dnet-site-force-override.properties</value>-->
<!-- <value>classpath*:dnet-force-override.properties</value>-->
</list>
</property>
</bean>
</beans>

View File

@ -10,6 +10,7 @@ springdoc:
displayRequestDuration: true
api-docs:
path: /api-docs
show-actuator: true
spring:
jpa: