develop #1
|
@ -0,0 +1,9 @@
|
||||||
|
# Provide
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
## Install and run:
|
||||||
|
- Run **git clone** and then **cd uoa-repository-manager-service**.
|
||||||
|
- Provide all not-set or redacted configurations, inside the **src/main/resources/application.properties** file.
|
||||||
|
- Build the app with: `mvn clean install -s <settings-file>`
|
||||||
|
- Run the app with: `java -jar ./target/uoa-repository-manager-service.jar`
|
|
@ -1,43 +0,0 @@
|
||||||
cd "${0%/*}" || (echo "Could not change-dir to this script's dir!" && exit) # Change the working directory to the script's directory, when running from other location.
|
|
||||||
|
|
||||||
if [[ $# -gt 1 ]]; then
|
|
||||||
echo -e "Wrong number of arguments given: ${#}\nPlease execute it like: installAndRun.sh <1 | 0 (optional)>"; exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
justRun=0
|
|
||||||
|
|
||||||
if [[ $# -eq 1 ]]; then # If we have just 1 argument.
|
|
||||||
numbers_re='^[0-9]+$'
|
|
||||||
if ! [[ $1 =~ $numbers_re ]]; then # If the first argument is not numeric.
|
|
||||||
echo -e "Invalid, non-numeric argument given: ${1}\nPlease execute it like: installAndRun.sh <1 | 0 (optional)>"; exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $1 -ne 0 && $1 -ne 1 ]]; then # If the 1st argument does NOT equal to < 0 > or < 1 >.
|
|
||||||
echo -e "Invalid argument given: ${1}\nPlease execute it like: installAndRun.sh <1 | 0 (optional)>"; exit 3
|
|
||||||
fi
|
|
||||||
|
|
||||||
justRun=$1 # Assign <1> or <0>
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnet_repo=~/.m2/repository-dnet45
|
|
||||||
settings_file=settings-dnet45.xml
|
|
||||||
|
|
||||||
if [[ justRun -eq 1 ]]; then
|
|
||||||
if [ ! -f ${dnet_repo}"/"${settings_file} ]; then
|
|
||||||
echo -e "The file \"~/.m2/repository-dnet45/settings-dnet45.xml\" does not exist! Exiting.." && exit 4
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [ ! -d ${dnet_repo} ]; then
|
|
||||||
mkdir ${dnet_repo} || (echo -e "The directory \"~/.m2/repository-dnet45/\" could not be created! Exiting.." && exit 5)
|
|
||||||
echo "Created the \"dnet_repo\": ${dnet_repo}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f ${dnet_repo}"/"${settings_file} ]; then
|
|
||||||
cp ${settings_file} ${dnet_repo}"/"${settings_file} || (echo -e "The file \"settings-dnet45.xml\" could not be copied in directory \"~/.m2/repository-dnet45\"! Exiting.." && exit 6)
|
|
||||||
echo "Copied the \"settings_file\" to: ${dnet_repo}/${settings_file}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mvn clean install -s ${dnet_repo}"/"${settings_file}
|
|
||||||
fi
|
|
||||||
|
|
||||||
java -jar ./target/uoa-repository-manager-service.jar
|
|
196
pom.xml
196
pom.xml
|
@ -12,7 +12,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>eu.dnetlib</groupId>
|
<groupId>eu.dnetlib</groupId>
|
||||||
<artifactId>uoa-repository-manager-service</artifactId>
|
<artifactId>uoa-repository-manager-service</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
@ -30,27 +30,21 @@
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-jdbc</artifactId>
|
<artifactId>spring-boot-starter-data-jdbc</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
|
||||||
<!--<scope>provided</scope>-->
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
@ -60,26 +54,23 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-validation</artifactId>
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-hystrix -->
|
<dependency>
|
||||||
<!--
|
<groupId>org.springframework.boot</groupId>
|
||||||
<dependency>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<scope>test</scope>
|
||||||
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
|
</dependency>
|
||||||
<version>2.2.9.RELEASE</version>
|
<dependency>
|
||||||
</dependency>
|
<groupId>com.h2database</groupId>
|
||||||
<dependency>
|
<artifactId>h2</artifactId>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
</dependency>
|
||||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
|
||||||
<version>3.0.1</version>
|
|
||||||
</dependency>
|
<dependency>
|
||||||
-->
|
<groupId>eu.dnetlib.dhp</groupId>
|
||||||
<!--
|
<artifactId>dnet-exporter-api</artifactId>
|
||||||
<dependency>
|
<version>[3.3.3-SNAPSHOT, )</version>
|
||||||
<groupId>javax.el</groupId>
|
</dependency>
|
||||||
<artifactId>javax.el-api</artifactId>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
-->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>eu.dnetlib</groupId>
|
<groupId>eu.dnetlib</groupId>
|
||||||
<artifactId>uoa-clients</artifactId>
|
<artifactId>uoa-clients</artifactId>
|
||||||
|
@ -122,36 +113,6 @@
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>org.springframework</groupId>-->
|
|
||||||
<!-- <artifactId>spring-webmvc</artifactId>-->
|
|
||||||
<!-- <version>${spring.version}</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>org.hibernate</groupId>-->
|
|
||||||
<!-- <artifactId>hibernate-validator-annotation-processor</artifactId>-->
|
|
||||||
<!-- <version>4.1.0.Final</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>log4j</groupId>-->
|
|
||||||
<!-- <artifactId>log4j</artifactId>-->
|
|
||||||
<!-- <version>${log4j.version}</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>eu.dnetlib</groupId>-->
|
|
||||||
<!-- <artifactId>uoa-domain</artifactId>-->
|
|
||||||
<!-- <version>[2.0.0-SNAPSHOT, 3.0.0)</version>-->
|
|
||||||
<!-- <exclusions>-->
|
|
||||||
<!-- <exclusion> <!– declare the exclusion here –>-->
|
|
||||||
<!-- <groupId>cglib</groupId>-->
|
|
||||||
<!-- <artifactId>cglib</artifactId>-->
|
|
||||||
<!-- </exclusion>-->
|
|
||||||
<!-- <exclusion>-->
|
|
||||||
<!-- <groupId>log4j</groupId>-->
|
|
||||||
<!-- <artifactId>log4j</artifactId>-->
|
|
||||||
<!-- </exclusion>-->
|
|
||||||
<!-- </exclusions>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>eu.dnetlib</groupId>
|
<groupId>eu.dnetlib</groupId>
|
||||||
<artifactId>dnet-openaire-usage-stats-sushilite</artifactId>
|
<artifactId>dnet-openaire-usage-stats-sushilite</artifactId>
|
||||||
|
@ -191,38 +152,6 @@
|
||||||
<version>2.7.2</version>
|
<version>2.7.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>xerces</groupId>-->
|
|
||||||
<!-- <artifactId>xercesImpl</artifactId>-->
|
|
||||||
<!-- <version>2.11.0</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<!--
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-core</artifactId>
|
|
||||||
<version>2.9.4</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
<version>2.9.4</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
-->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>org.springframework</groupId>-->
|
|
||||||
<!-- <artifactId>spring-context</artifactId>-->
|
|
||||||
<!-- <version>${spring.version}</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>org.springframework</groupId>-->
|
|
||||||
<!-- <artifactId>spring-jdbc</artifactId>-->
|
|
||||||
<!-- <version>${spring.version}</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.jersey</groupId>
|
<groupId>com.sun.jersey</groupId>
|
||||||
<artifactId>jersey-client</artifactId>
|
<artifactId>jersey-client</artifactId>
|
||||||
|
@ -264,13 +193,6 @@
|
||||||
<version>9.1-901.jdbc3</version>
|
<version>9.1-901.jdbc3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-catalina -->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>org.apache.tomcat</groupId>-->
|
|
||||||
<!-- <artifactId>tomcat-catalina</artifactId>-->
|
|
||||||
<!-- <version>9.0.22</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-fileupload</groupId>
|
<groupId>commons-fileupload</groupId>
|
||||||
<artifactId>commons-fileupload</artifactId>
|
<artifactId>commons-fileupload</artifactId>
|
||||||
|
@ -292,14 +214,6 @@
|
||||||
<groupId>org.springframework.session</groupId>
|
<groupId>org.springframework.session</groupId>
|
||||||
<artifactId>spring-session-data-redis</artifactId>
|
<artifactId>spring-session-data-redis</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.session</groupId>
|
|
||||||
<artifactId>spring-session-data-redis</artifactId>
|
|
||||||
<version>2.5.1</version>
|
|
||||||
<type>pom</type>
|
|
||||||
</dependency>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
|
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -323,18 +237,7 @@
|
||||||
<artifactId>cors-filter</artifactId>
|
<artifactId>cors-filter</artifactId>
|
||||||
<version>2.5</version>
|
<version>2.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.netflix.hystrix</groupId>
|
|
||||||
<artifactId>hystrix-core</artifactId>
|
|
||||||
<version>1.5.18</version>
|
|
||||||
</dependency>
|
|
||||||
<!--
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.netflix.rxjava</groupId>
|
|
||||||
<artifactId>rxjava-core</artifactId>
|
|
||||||
<version>0.20.7</version>
|
|
||||||
</dependency>
|
|
||||||
-->
|
|
||||||
<!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
|
<!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.xml.ws</groupId>
|
<groupId>javax.xml.ws</groupId>
|
||||||
|
@ -381,37 +284,6 @@
|
||||||
<!-- </exclusions>-->
|
<!-- </exclusions>-->
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.mockito</groupId>
|
|
||||||
<artifactId>mockito-core</artifactId>
|
|
||||||
<version>2.26.0</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Enable micrometer >> -->
|
|
||||||
<!-- <dependency> <!– TODO: remove this with ActuatorConfig class –>-->
|
|
||||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
|
||||||
<!-- <artifactId>spring-boot-actuator</artifactId>-->
|
|
||||||
<!-- <version>1.3.5.RELEASE</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
|
||||||
<!-- <artifactId>spring-boot-actuator-autoconfigure</artifactId>-->
|
|
||||||
<!-- <version>2.1.18.RELEASE</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>io.micrometer</groupId>-->
|
|
||||||
<!-- <artifactId>micrometer-core</artifactId>-->
|
|
||||||
<!-- <version>1.7.2</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.micrometer</groupId>
|
|
||||||
<artifactId>micrometer-registry-prometheus</artifactId>
|
|
||||||
<version>1.7.2</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- << Enable micrometer -->
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
@ -520,30 +392,6 @@
|
||||||
<enabled>false</enabled>
|
<enabled>false</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
|
||||||
<id>dnet45-bootstrap-snapshot</id>
|
|
||||||
<name>D-Net 45 Bootstrap Snapshot</name>
|
|
||||||
<url>https://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-bootstrap-snapshot</url>
|
|
||||||
<releases>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</releases>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
<layout>default</layout>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>dnet45-bootstrap-release</id>
|
|
||||||
<name>D-Net 45 Bootstrap Release</name>
|
|
||||||
<url>https://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-bootstrap-release</url>
|
|
||||||
<releases>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</releases>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
<layout>default</layout>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
|
|
||||||
<localRepository>${env.HOME}/.m2/repository-dnet45</localRepository>
|
|
||||||
<pluginGroups>
|
|
||||||
<pluginGroup>org.apache.tomcat.maven</pluginGroup>
|
|
||||||
</pluginGroups>
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>dnet4.0</id>
|
|
||||||
<activation>
|
|
||||||
<activeByDefault>true</activeByDefault>
|
|
||||||
</activation>
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>dnet45-bootstrap-snapshot</id>
|
|
||||||
<name>D-Net 45 Bootstrap Snapshot</name>
|
|
||||||
<url>https://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-bootstrap-snapshot</url>
|
|
||||||
<releases>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</releases>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
<layout>default</layout>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>dnet45-bootstrap-release</id>
|
|
||||||
<name>D-Net 45 Bootstrap Release</name>
|
|
||||||
<url>https://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-bootstrap-release</url>
|
|
||||||
<releases>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</releases>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
<layout>default</layout>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
</settings>
|
|
|
@ -15,7 +15,6 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.builders.WebSecurity;
|
import org.springframework.security.config.annotation.web.builders.WebSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
|
|
||||||
import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter;
|
import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.dnetlib.repo.manager.config;
|
package eu.dnetlib.repo.manager.config;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
||||||
|
@ -15,7 +16,7 @@ public class AsyncConfiguration implements AsyncConfigurer {
|
||||||
@Override
|
@Override
|
||||||
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
||||||
return new AsyncUncaughtExceptionHandler() {
|
return new AsyncUncaughtExceptionHandler() {
|
||||||
private final Logger logger = Logger.getLogger(getClass());
|
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleUncaughtException(Throwable throwable, Method method, Object... objects) {
|
public void handleUncaughtException(Throwable throwable, Method method, Object... objects) {
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package eu.dnetlib.repo.manager.config;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.MapperFeature;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class CustomRestTemplateConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RestTemplate restTemplate() {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
restTemplate.getMessageConverters().add(0, mappingJacksonHttpMessageConverter());
|
||||||
|
return restTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter() {
|
||||||
|
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
|
||||||
|
converter.setObjectMapper(customObjectMapper());
|
||||||
|
return converter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ObjectMapper customObjectMapper() {
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
// Do not fail when reading unknown properties
|
||||||
|
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
// Do not fail when reading properties of different case
|
||||||
|
objectMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
|
||||||
|
|
||||||
|
return objectMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,59 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.config;
|
|
||||||
|
|
||||||
import org.apache.commons.dbcp.BasicDataSource;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableTransactionManagement
|
|
||||||
public class DatasourceConfiguration {
|
|
||||||
|
|
||||||
private static Logger LOGGER = Logger.getLogger(DatasourceConfiguration.class);
|
|
||||||
|
|
||||||
@Value("${services.provide.db.driverClassName}")
|
|
||||||
private String driverClassname;
|
|
||||||
|
|
||||||
@Value("${services.provide.db.url}")
|
|
||||||
private String URL;
|
|
||||||
|
|
||||||
@Value("${services.provide.db.username}")
|
|
||||||
private String username;
|
|
||||||
|
|
||||||
@Value("${services.provide.db.password}")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public BasicDataSource dataSource(){
|
|
||||||
BasicDataSource basicDataSource = new BasicDataSource();
|
|
||||||
basicDataSource.setDriverClassName(driverClassname);
|
|
||||||
basicDataSource.setUrl(URL);
|
|
||||||
basicDataSource.setUsername(username);
|
|
||||||
basicDataSource.setPassword(password);
|
|
||||||
basicDataSource.setMaxIdle(10);
|
|
||||||
basicDataSource.setMaxActive(100);
|
|
||||||
basicDataSource.setMaxWait(1000);
|
|
||||||
basicDataSource.setValidationQuery("SELECT 1;");
|
|
||||||
basicDataSource.setTestOnBorrow(true);
|
|
||||||
basicDataSource.setTestOnReturn(true);
|
|
||||||
basicDataSource.setTestWhileIdle(true);
|
|
||||||
basicDataSource.setTimeBetweenEvictionRunsMillis(1200000);
|
|
||||||
basicDataSource.setMinEvictableIdleTimeMillis(1800000);
|
|
||||||
basicDataSource.setMinEvictableIdleTimeMillis(5);
|
|
||||||
basicDataSource.setPoolPreparedStatements(true);
|
|
||||||
basicDataSource.setDefaultAutoCommit(true);
|
|
||||||
|
|
||||||
return basicDataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public DataSourceTransactionManager txManager(){
|
|
||||||
DataSourceTransactionManager txManager = new DataSourceTransactionManager();
|
|
||||||
txManager.setDataSource(dataSource());
|
|
||||||
return txManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,8 +1,9 @@
|
||||||
package eu.dnetlib.repo.manager.config;
|
package eu.dnetlib.repo.manager.config;
|
||||||
|
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
||||||
|
@ -22,25 +23,26 @@ public class FrontEndLinkURIAuthenticationSuccessHandler implements Authenticati
|
||||||
|
|
||||||
private String frontEndURI;
|
private String frontEndURI;
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger
|
private static final Logger logger = LoggerFactory.getLogger(FrontEndLinkURIAuthenticationSuccessHandler.class);
|
||||||
.getLogger(FrontEndLinkURIAuthenticationSuccessHandler.class);
|
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
LOGGER.debug("Front end uri : " + frontEndURI);
|
logger.debug("Front end uri : {}", frontEndURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Value("${services.provide.aai.oidc.domain}")
|
@Value("${services.provide.aai.oidc.domain}")
|
||||||
private String domain;
|
private String domain;
|
||||||
|
|
||||||
|
|
||||||
|
private static final Pattern AUTH_REGEX = Pattern.compile("^([A-Za-z0-9-_=]+)\\.([A-Za-z0-9-_=]+)\\.?([A-Za-z0-9-_.+=]*)$");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
||||||
OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
|
OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
|
||||||
request.getSession().setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, authOIDC.getUserInfo().getEmail());
|
request.getSession().setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, authOIDC.getUserInfo().getSub());
|
||||||
|
|
||||||
Cookie accessToken = new Cookie("AccessToken", authOIDC.getAccessTokenValue());
|
Cookie accessToken = new Cookie("AccessToken", authOIDC.getAccessTokenValue());
|
||||||
String regex = "^([A-Za-z0-9-_=]+)\\.([A-Za-z0-9-_=]+)\\.?([A-Za-z0-9-_.+=]*)$";
|
Matcher matcher = AUTH_REGEX.matcher(authOIDC.getAccessTokenValue());
|
||||||
Matcher matcher = Pattern.compile(regex).matcher(authOIDC.getAccessTokenValue());
|
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
long exp = new JsonParser().parse(new String(Base64.getDecoder().decode(matcher.group(2)))).getAsJsonObject().get("exp").getAsLong();
|
long exp = new JsonParser().parse(new String(Base64.getDecoder().decode(matcher.group(2)))).getAsJsonObject().get("exp").getAsLong();
|
||||||
accessToken.setMaxAge((int) (exp - (new Date().getTime() / 1000)));
|
accessToken.setMaxAge((int) (exp - (new Date().getTime() / 1000)));
|
||||||
|
|
|
@ -3,9 +3,10 @@ package eu.dnetlib.repo.manager.config;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.nimbusds.jwt.JWT;
|
import com.nimbusds.jwt.JWT;
|
||||||
import eu.dnetlib.repo.manager.service.security.AuthoritiesMapper;
|
import eu.dnetlib.repo.manager.service.security.AuthoritiesMapper;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.mitre.openid.connect.client.OIDCAuthoritiesMapper;
|
import org.mitre.openid.connect.client.OIDCAuthoritiesMapper;
|
||||||
import org.mitre.openid.connect.model.UserInfo;
|
import org.mitre.openid.connect.model.UserInfo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
|
@ -18,7 +19,7 @@ import java.util.Set;
|
||||||
@Component
|
@Component
|
||||||
public class OpenAIREAuthoritiesMapper implements OIDCAuthoritiesMapper {
|
public class OpenAIREAuthoritiesMapper implements OIDCAuthoritiesMapper {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(OpenAIREAuthoritiesMapper.class);
|
private static final Logger logger = LoggerFactory.getLogger(OpenAIREAuthoritiesMapper.class);
|
||||||
|
|
||||||
@Value("${services.provide.adminEmail}")
|
@Value("${services.provide.adminEmail}")
|
||||||
String adminEmail;
|
String adminEmail;
|
||||||
|
@ -33,7 +34,7 @@ public class OpenAIREAuthoritiesMapper implements OIDCAuthoritiesMapper {
|
||||||
} else if (userInfo.getSource().getAsJsonArray("eduperson_entitlement") != null) {
|
} else if (userInfo.getSource().getAsJsonArray("eduperson_entitlement") != null) {
|
||||||
entitlements = userInfo.getSource().getAsJsonArray("eduperson_entitlement");
|
entitlements = userInfo.getSource().getAsJsonArray("eduperson_entitlement");
|
||||||
}
|
}
|
||||||
logger.debug("user info: " + userInfo + "\nentitlements: " + entitlements);
|
logger.debug("user info: {}\nentitlements: {}", userInfo, entitlements);
|
||||||
|
|
||||||
// FIXME: delete this if statement when super administrators are set
|
// FIXME: delete this if statement when super administrators are set
|
||||||
if (userInfo.getEmail() != null && userInfo.getEmail().equals(adminEmail)) {
|
if (userInfo.getEmail() != null && userInfo.getEmail().equals(adminEmail)) {
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
package eu.dnetlib.repo.manager.config;
|
package eu.dnetlib.repo.manager.config;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
|
||||||
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
|
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
|
||||||
import org.springframework.session.web.http.CookieSerializer;
|
import org.springframework.session.web.http.CookieSerializer;
|
||||||
import org.springframework.session.web.http.DefaultCookieSerializer;
|
import org.springframework.session.web.http.DefaultCookieSerializer;
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
@ -18,7 +16,7 @@ import javax.annotation.PostConstruct;
|
||||||
@EnableRedisHttpSession
|
@EnableRedisHttpSession
|
||||||
public class RedisConfiguration {
|
public class RedisConfiguration {
|
||||||
|
|
||||||
private static Logger LOGGER = Logger.getLogger(RedisConfiguration.class);
|
private static final Logger logger = LoggerFactory.getLogger(RedisConfiguration.class);
|
||||||
|
|
||||||
@Value("${services.provide.redis.host}")
|
@Value("${services.provide.redis.host}")
|
||||||
private String host;
|
private String host;
|
||||||
|
@ -34,12 +32,12 @@ public class RedisConfiguration {
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void init() {
|
private void init() {
|
||||||
LOGGER.info(String.format("Redis : %s Port : %s Password : %s", host, port, password));
|
logger.info(String.format("Redis : %s Port : %s Password : %s", host, port, password));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public JedisConnectionFactory connectionFactory() {
|
public JedisConnectionFactory connectionFactory() {
|
||||||
LOGGER.info(String.format("Redis : %s Port : %s Password : %s", host, port, password));
|
logger.info(String.format("Redis : %s Port : %s Password : %s", host, port, password));
|
||||||
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
|
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
|
||||||
jedisConnectionFactory.setHostName(host);
|
jedisConnectionFactory.setHostName(host);
|
||||||
jedisConnectionFactory.setPort(Integer.parseInt(port));
|
jedisConnectionFactory.setPort(Integer.parseInt(port));
|
||||||
|
@ -54,18 +52,8 @@ public class RedisConfiguration {
|
||||||
serializer.setCookieName("openAIRESession");
|
serializer.setCookieName("openAIRESession");
|
||||||
serializer.setCookiePath("/");
|
serializer.setCookiePath("/");
|
||||||
serializer.setDomainName(domain);
|
serializer.setDomainName(domain);
|
||||||
LOGGER.info("Serializer : " + serializer);
|
logger.info("Cookie Serializer : {}", serializer);
|
||||||
return serializer;
|
return serializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
public RestTemplate restTemplate() {
|
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
|
||||||
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
|
||||||
HttpHeaders httpHeaders = new HttpHeaders();
|
|
||||||
httpHeaders.set("Content-Type", "application/json");
|
|
||||||
return restTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package eu.dnetlib.repo.manager.controllers;
|
package eu.dnetlib.repo.manager.controllers;
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
|
||||||
import eu.dnetlib.repo.manager.domain.Term;
|
import eu.dnetlib.repo.manager.domain.Term;
|
||||||
import eu.dnetlib.repo.manager.domain.broker.*;
|
import eu.dnetlib.repo.manager.domain.broker.*;
|
||||||
|
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||||
import eu.dnetlib.repo.manager.service.BrokerServiceImpl;
|
import eu.dnetlib.repo.manager.service.BrokerServiceImpl;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package eu.dnetlib.repo.manager.controllers;
|
package eu.dnetlib.repo.manager.controllers;
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.domain.*;
|
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
|
||||||
|
import eu.dnetlib.repo.manager.domain.BrokerSummary;
|
||||||
|
import eu.dnetlib.repo.manager.domain.CollectionMonitorSummary;
|
||||||
|
import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo;
|
||||||
|
import eu.dnetlib.repo.manager.domain.UsageSummary;
|
||||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||||
import eu.dnetlib.repo.manager.service.BrokerService;
|
import eu.dnetlib.repo.manager.service.*;
|
||||||
import eu.dnetlib.repo.manager.service.DashboardService;
|
|
||||||
import eu.dnetlib.repo.manager.service.PiWikService;
|
|
||||||
import eu.dnetlib.repo.manager.service.RepositoryService;
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||||
|
@ -29,6 +30,9 @@ public class DashboardController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RepositoryService repositoryService;
|
private RepositoryService repositoryService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AggregationService aggregationService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BrokerService brokerService;
|
private BrokerService brokerService;
|
||||||
|
|
||||||
|
@ -53,20 +57,20 @@ public class DashboardController {
|
||||||
@PathVariable("repoId") String repoId,
|
@PathVariable("repoId") String repoId,
|
||||||
@RequestParam(name = "size", required = false, defaultValue = "20") int size) throws JSONException {
|
@RequestParam(name = "size", required = false, defaultValue = "20") int size) throws JSONException {
|
||||||
|
|
||||||
List<AggregationDetails> aggregationDetails = repositoryService.getRepositoryAggregations(repoId, 0, size);
|
List<AggregationInfo> aggregationInfo = aggregationService.getRepositoryAggregations(repoId, 0, size);
|
||||||
CollectionMonitorSummary collectionMonitorSummary = new CollectionMonitorSummary();
|
CollectionMonitorSummary collectionMonitorSummary = new CollectionMonitorSummary();
|
||||||
collectionMonitorSummary.setAggregationDetails(aggregationDetails);
|
collectionMonitorSummary.setAggregationInfo(aggregationInfo);
|
||||||
size = 0;
|
size = 0;
|
||||||
do {
|
do {
|
||||||
aggregationDetails = repositoryService.getRepositoryAggregations(repoId, size, size + 50);
|
aggregationInfo = aggregationService.getRepositoryAggregations(repoId, size, size + 50);
|
||||||
for (AggregationDetails aggregationDetail : aggregationDetails) {
|
for (AggregationInfo aggregationDetail : aggregationInfo) {
|
||||||
if (aggregationDetail.getIndexedVersion()) {
|
if (aggregationDetail.isIndexedVersion()) {
|
||||||
collectionMonitorSummary.setLastIndexedVersion(aggregationDetail);
|
collectionMonitorSummary.setLastIndexedVersion(aggregationDetail);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
size += 30;
|
size += 30;
|
||||||
} while (aggregationDetails.size() != 0 && collectionMonitorSummary.getLastIndexedVersion() == null);
|
} while (aggregationInfo.size() != 0 && collectionMonitorSummary.getLastIndexedVersion() == null);
|
||||||
|
|
||||||
return collectionMonitorSummary;
|
return collectionMonitorSummary;
|
||||||
}
|
}
|
||||||
|
@ -90,5 +94,4 @@ public class DashboardController {
|
||||||
return new BrokerSummary(brokerService.getSimpleSubscriptionsOfUser(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail()), brokerService.getTopicsForDatasource(datasourceName));
|
return new BrokerSummary(brokerService.getSimpleSubscriptionsOfUser(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail()), brokerService.getTopicsForDatasource(datasourceName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@ import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||||
import eu.dnetlib.repo.manager.exception.EndPointException;
|
import eu.dnetlib.repo.manager.exception.EndPointException;
|
||||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||||
import eu.dnetlib.repo.manager.exception.ServerError;
|
import eu.dnetlib.repo.manager.exception.ServerError;
|
||||||
import org.apache.log4j.LogManager;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
@ -26,7 +26,7 @@ import java.net.UnknownHostException;
|
||||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||||
public class GenericControllerAdvice {
|
public class GenericControllerAdvice {
|
||||||
|
|
||||||
private Logger logger = LogManager.getLogger(GenericControllerAdvice.class);
|
private Logger logger = LoggerFactory.getLogger(GenericControllerAdvice.class);
|
||||||
|
|
||||||
|
|
||||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package eu.dnetlib.repo.manager.controllers;
|
||||||
|
|
||||||
|
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequest;
|
||||||
|
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequestId;
|
||||||
|
import eu.dnetlib.repo.manager.domain.dto.InterfaceComplianceRequestDTO;
|
||||||
|
import eu.dnetlib.repo.manager.service.InterfaceComplianceService;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("compliance")
|
||||||
|
public class InterfaceComplianceRequestController {
|
||||||
|
|
||||||
|
private final InterfaceComplianceService service;
|
||||||
|
|
||||||
|
public InterfaceComplianceRequestController(InterfaceComplianceService service) {
|
||||||
|
this.service = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("{repositoryId}/{interfaceId}")
|
||||||
|
public InterfaceComplianceRequest get(@PathVariable("repositoryId") String repositoryId, @PathVariable("interfaceId") String interfaceId) {
|
||||||
|
InterfaceComplianceRequestId id = new InterfaceComplianceRequestId();
|
||||||
|
id.setRepositoryId(repositoryId);
|
||||||
|
id.setInterfaceId(interfaceId);
|
||||||
|
return service.getById(id).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping()
|
||||||
|
public Iterable<InterfaceComplianceRequest> get() {
|
||||||
|
return service.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping()
|
||||||
|
public InterfaceComplianceRequest add(@RequestBody InterfaceComplianceRequestDTO requestDTO) {
|
||||||
|
requestDTO.setSubmissionDate(new Date());
|
||||||
|
return service.create(InterfaceComplianceRequest.from(requestDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("{repositoryId}/{interfaceId}")
|
||||||
|
public void delete(@PathVariable("repositoryId") String repositoryId, @PathVariable("interfaceId") String interfaceId) {
|
||||||
|
InterfaceComplianceRequestId id = new InterfaceComplianceRequestId();
|
||||||
|
id.setRepositoryId(repositoryId);
|
||||||
|
id.setInterfaceId(interfaceId);
|
||||||
|
this.service.delete(id);
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,9 +6,10 @@ import eu.dnetlib.repo.manager.domain.JobsOfUser;
|
||||||
import eu.dnetlib.repo.manager.service.MonitorServiceImpl;
|
import eu.dnetlib.repo.manager.service.MonitorServiceImpl;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
@ -20,8 +21,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
@Api(description = "Monitor API", tags = {"monitor"})
|
@Api(description = "Monitor API", tags = {"monitor"})
|
||||||
public class MonitorController {
|
public class MonitorController {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger
|
private static final Logger logger = LoggerFactory.getLogger(MonitorController.class);
|
||||||
.getLogger(MonitorController.class);
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MonitorServiceImpl monitorService;
|
private MonitorServiceImpl monitorService;
|
||||||
|
|
|
@ -9,7 +9,8 @@ import eu.dnetlib.repo.manager.service.PiWikServiceImpl;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
import org.apache.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.io.FileSystemResource;
|
import org.springframework.core.io.FileSystemResource;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
@ -33,8 +34,7 @@ import java.util.List;
|
||||||
@Api(description = "Piwik API", tags = {"piwik"})
|
@Api(description = "Piwik API", tags = {"piwik"})
|
||||||
public class PiWikController {
|
public class PiWikController {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger
|
private static final Logger logger = LoggerFactory.getLogger(PiWikController.class);
|
||||||
.getLogger(PiWikController.class);
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PiWikServiceImpl piWikService;
|
private PiWikServiceImpl piWikService;
|
||||||
|
@ -76,6 +76,7 @@ public class PiWikController {
|
||||||
results.setResults(returning);
|
results.setResults(returning);
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name = "from", dataType = "number", paramType = "query"),
|
@ApiImplicitParam(name = "from", dataType = "number", paramType = "query"),
|
||||||
@ApiImplicitParam(name = "quantity", dataType = "number", paramType = "query"),
|
@ApiImplicitParam(name = "quantity", dataType = "number", paramType = "query"),
|
||||||
|
@ -103,25 +104,22 @@ public class PiWikController {
|
||||||
sb.append(" Repository ID , Repository name, Country, Site ID, Authentication token, Creation date, Requestor full name, Requestor email, Validated, Validation date, Comment \n");
|
sb.append(" Repository ID , Repository name, Country, Site ID, Authentication token, Creation date, Requestor full name, Requestor email, Validated, Validation date, Comment \n");
|
||||||
|
|
||||||
for(PiwikInfo piwikInfo : returning){
|
for(PiwikInfo piwikInfo : returning){
|
||||||
sb.append(
|
sb.append(piwikInfo.getRepositoryId() == null ? "," : piwikInfo.getRepositoryId() + ",")
|
||||||
(piwikInfo.getRepositoryId() == null ? "," : piwikInfo.getRepositoryId()+ ",")+
|
.append(piwikInfo.getRepositoryName() == null ? "," : piwikInfo.getRepositoryName() + ",")
|
||||||
(piwikInfo.getRepositoryName() == null ? "," : piwikInfo.getRepositoryName()+ ",")+
|
.append(piwikInfo.getCountry() == null ? "," : piwikInfo.getCountry() + ",")
|
||||||
(piwikInfo.getCountry() == null ? "," : piwikInfo.getCountry()+ ",")+
|
.append(piwikInfo.getSiteId() == null ? "," : piwikInfo.getSiteId() + ",")
|
||||||
(piwikInfo.getSiteId() == null ? "," : piwikInfo.getSiteId()+ ",") +
|
.append(piwikInfo.getAuthenticationToken() == null ? "," : piwikInfo.getAuthenticationToken() + ",")
|
||||||
(piwikInfo.getAuthenticationToken() == null ? "," : piwikInfo.getAuthenticationToken()+ ",")+
|
.append(piwikInfo.getCreationDate() == null ? "," : piwikInfo.getCreationDate().toString() + ",")
|
||||||
(piwikInfo.getCreationDate() == null ? "," : piwikInfo.getCreationDate().toString()+ ",") +
|
.append(piwikInfo.getRequestorName() == null ? "," : piwikInfo.getRequestorName() + ",")
|
||||||
(piwikInfo.getRequestorName() == null ? "," : piwikInfo.getRequestorName()+ ",") +
|
.append(piwikInfo.getRequestorEmail() == null ? "," : piwikInfo.getRequestorEmail() + ",")
|
||||||
(piwikInfo.getRequestorEmail() == null ? "," : piwikInfo.getRequestorEmail()+ ",")+
|
.append(piwikInfo.isValidated()).append(",")
|
||||||
piwikInfo.isValidated() + "," +
|
.append(piwikInfo.getValidationDate() == null ? "," : piwikInfo.getValidationDate().toString() + ",")
|
||||||
(piwikInfo.getValidationDate() == null ? "," : piwikInfo.getValidationDate().toString()+ ",") +
|
.append(piwikInfo.getComment() == null ? "\n" : piwikInfo.getComment() + "\n");
|
||||||
(piwikInfo.getComment() == null ? "\n" : piwikInfo.getComment()+ "\n")
|
|
||||||
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
writer.write(sb.toString());
|
writer.write(sb.toString());
|
||||||
|
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
LOGGER.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,7 +139,6 @@ public class PiWikController {
|
||||||
strDate);
|
strDate);
|
||||||
response.setHeader(headerKey, headerValue);
|
response.setHeader(headerKey, headerValue);
|
||||||
|
|
||||||
|
|
||||||
return new FileSystemResource(p.toFile());
|
return new FileSystemResource(p.toFile());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@ import io.micrometer.core.instrument.binder.system.UptimeMetrics;
|
||||||
import io.micrometer.prometheus.PrometheusConfig;
|
import io.micrometer.prometheus.PrometheusConfig;
|
||||||
import io.micrometer.prometheus.PrometheusMeterRegistry;
|
import io.micrometer.prometheus.PrometheusMeterRegistry;
|
||||||
import io.prometheus.client.exporter.common.TextFormat;
|
import io.prometheus.client.exporter.common.TextFormat;
|
||||||
import org.apache.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
@ -24,7 +25,7 @@ import java.io.File;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/actuator/prometheus")
|
@RequestMapping("/actuator/prometheus")
|
||||||
public class PrometheusController { // TODO: remove this with migration to Spring Boot 2
|
public class PrometheusController { // TODO: remove this with migration to Spring Boot 2
|
||||||
private static final Logger LOGGER = Logger.getLogger(PrometheusController.class);
|
private static final Logger logger = LoggerFactory.getLogger(PrometheusController.class);
|
||||||
|
|
||||||
private final PiWikService piWikService;
|
private final PiWikService piWikService;
|
||||||
private final RepositoryService repositoryService;
|
private final RepositoryService repositoryService;
|
||||||
|
@ -52,7 +53,7 @@ public class PrometheusController { // TODO: remove this with migration to Sprin
|
||||||
try (JvmGcMetrics jvmGcMetrics = new JvmGcMetrics() ) {
|
try (JvmGcMetrics jvmGcMetrics = new JvmGcMetrics() ) {
|
||||||
jvmGcMetrics.bindTo(registry);
|
jvmGcMetrics.bindTo(registry);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("", e);
|
logger.error("", e);
|
||||||
}
|
}
|
||||||
new JvmMemoryMetrics().bindTo(registry);
|
new JvmMemoryMetrics().bindTo(registry);
|
||||||
new DiskSpaceMetrics(new File("/")).bindTo(registry);
|
new DiskSpaceMetrics(new File("/")).bindTo(registry);
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
package eu.dnetlib.repo.manager.controllers;
|
package eu.dnetlib.repo.manager.controllers;
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.domain.Repository;
|
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
|
||||||
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
|
|
||||||
import eu.dnetlib.repo.manager.domain.*;
|
import eu.dnetlib.repo.manager.domain.*;
|
||||||
import eu.dnetlib.repo.manager.domain.dto.RepositoryTerms;
|
import eu.dnetlib.repo.manager.domain.dto.RepositoryTerms;
|
||||||
import eu.dnetlib.repo.manager.domain.dto.User;
|
import eu.dnetlib.repo.manager.domain.dto.User;
|
||||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||||
|
import eu.dnetlib.repo.manager.service.AggregationService;
|
||||||
import eu.dnetlib.repo.manager.service.RepositoryService;
|
import eu.dnetlib.repo.manager.service.RepositoryService;
|
||||||
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
||||||
import eu.dnetlib.repo.manager.utils.JsonUtils;
|
import eu.dnetlib.repo.manager.utils.JsonUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
@ -35,15 +36,19 @@ import java.util.Map;
|
||||||
@Api(description = "Repository API", tags = {"repositories"})
|
@Api(description = "Repository API", tags = {"repositories"})
|
||||||
public class RepositoryController {
|
public class RepositoryController {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(RepositoryController.class);
|
private static final Logger logger = LoggerFactory.getLogger(RepositoryController.class);
|
||||||
|
|
||||||
private final RepositoryService repositoryService;
|
private final RepositoryService repositoryService;
|
||||||
|
|
||||||
|
private final AggregationService aggregationService;
|
||||||
|
|
||||||
private final AuthorizationService authorizationService;
|
private final AuthorizationService authorizationService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RepositoryController(RepositoryService repositoryService,
|
RepositoryController(RepositoryService repositoryService,
|
||||||
AuthorizationService authorizationService) {
|
AggregationService aggregationService, AuthorizationService authorizationService) {
|
||||||
this.repositoryService = repositoryService;
|
this.repositoryService = repositoryService;
|
||||||
|
this.aggregationService = aggregationService;
|
||||||
this.authorizationService = authorizationService;
|
this.authorizationService = authorizationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,15 +126,15 @@ public class RepositoryController {
|
||||||
@RequestMapping(value = "/getRepositoryAggregations/{id}", method = RequestMethod.GET,
|
@RequestMapping(value = "/getRepositoryAggregations/{id}", method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<AggregationDetails> getRepositoryAggregations(@PathVariable("id") String id) throws JSONException {
|
public List<AggregationInfo> getRepositoryAggregations(@PathVariable("id") String id) throws JSONException {
|
||||||
return repositoryService.getRepositoryAggregations(id, 0, 20);
|
return aggregationService.getRepositoryAggregations(id, 0, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getRepositoryAggregationsByYear/{id}", method = RequestMethod.GET,
|
@RequestMapping(value = "/getRepositoryAggregationsByYear/{id}", method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String, List<AggregationDetails>> getRepositoryAggregationsByYear(@PathVariable("id") String id) throws JSONException {
|
public Map<String, List<AggregationInfo>> getRepositoryAggregationsByYear(@PathVariable("id") String id) throws JSONException {
|
||||||
return repositoryService.getRepositoryAggregationsByYear(id);
|
return aggregationService.getRepositoryAggregationsByYear(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getRepositoriesByName/{name:.+}/{page}/{size}/", method = RequestMethod.GET,
|
@RequestMapping(value = "/getRepositoriesByName/{name:.+}/{page}/{size}/", method = RequestMethod.GET,
|
||||||
|
@ -205,9 +210,10 @@ public class RepositoryController {
|
||||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
|
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
|
||||||
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
|
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
|
||||||
@RequestParam("repoId") String id,
|
@RequestParam("repoId") String id,
|
||||||
|
@RequestParam(required = false, name = "desiredCompatibilityLevel") String desiredCompatibilityLevel,
|
||||||
@RequestParam(value = "comment", required = false) String comment,
|
@RequestParam(value = "comment", required = false) String comment,
|
||||||
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
||||||
return repositoryService.addRepositoryInterface(datatype, id, comment, repositoryInterface);
|
return repositoryService.addRepositoryInterface(datatype, id, comment, repositoryInterface, desiredCompatibilityLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/updateRepositoryInterface", method = RequestMethod.POST,
|
@RequestMapping(value = "/updateRepositoryInterface", method = RequestMethod.POST,
|
||||||
|
@ -215,9 +221,10 @@ public class RepositoryController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
|
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
|
||||||
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String id,
|
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String id,
|
||||||
|
@RequestParam(required = false, name = "desiredCompatibilityLevel") String desiredCompatibilityLevel,
|
||||||
@RequestParam(value = "comment", required = false) String comment,
|
@RequestParam(value = "comment", required = false) String comment,
|
||||||
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
||||||
return repositoryService.updateRepositoryInterface(id, comment, repositoryInterface);
|
return repositoryService.updateRepositoryInterface(id, comment, repositoryInterface, desiredCompatibilityLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getUrlsOfUserRepos/{page}/{size}/", method = RequestMethod.GET,
|
@RequestMapping(value = "/getUrlsOfUserRepos/{page}/{size}/", method = RequestMethod.GET,
|
||||||
|
|
|
@ -19,8 +19,7 @@ public class StatsController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private StatsServiceImpl statsService;
|
private StatsServiceImpl statsService;
|
||||||
|
|
||||||
@RequestMapping(value = "/getStatistics" , method = RequestMethod.GET,
|
@RequestMapping(value = "/getStatistics" , method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map getStatistics(){
|
public Map getStatistics(){
|
||||||
return statsService.getStatistics();
|
return statsService.getStatistics();
|
||||||
|
|
|
@ -6,7 +6,6 @@ import eu.dnetlib.repo.manager.service.security.AuthoritiesUpdater;
|
||||||
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
||||||
import eu.dnetlib.repo.manager.service.security.RoleMappingService;
|
import eu.dnetlib.repo.manager.service.security.RoleMappingService;
|
||||||
import eu.dnetlib.repo.manager.utils.JsonUtils;
|
import eu.dnetlib.repo.manager.utils.JsonUtils;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
@ -97,7 +96,7 @@ public class UserRoleController {
|
||||||
@RequestMapping(method = RequestMethod.GET, path = "/users/{email}/roles")
|
@RequestMapping(method = RequestMethod.GET, path = "/users/{email}/roles")
|
||||||
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or hasAuthority('REGISTERED_USER') and authentication.userInfo.email==#email")
|
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or hasAuthority('REGISTERED_USER') and authentication.userInfo.email==#email")
|
||||||
public ResponseEntity<Collection<String>> getRolesByEmail(@PathVariable("email") String email) {
|
public ResponseEntity<Collection<String>> getRolesByEmail(@PathVariable("email") String email) {
|
||||||
return ResponseEntity.ok(authorizationService.getUserRoles(email));
|
return ResponseEntity.ok(authorizationService.getUserRolesByEmail(email));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||||
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
||||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||||
import eu.dnetlib.repo.manager.domain.InterfaceInformation;
|
import eu.dnetlib.repo.manager.domain.InterfaceInformation;
|
||||||
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
|
||||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||||
|
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
||||||
import eu.dnetlib.repo.manager.service.EmailUtils;
|
import eu.dnetlib.repo.manager.service.EmailUtils;
|
||||||
import eu.dnetlib.repo.manager.service.ValidatorServiceImpl;
|
import eu.dnetlib.repo.manager.service.ValidatorServiceImpl;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
@ -112,8 +112,8 @@ public class ValidatorController {
|
||||||
@RequestMapping(value = "/complete" , method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/complete" , method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public void validationCompleted(
|
public void validationCompleted(
|
||||||
@RequestParam(value = "interfaceId") String interfaceId,
|
|
||||||
@RequestParam(value = "repoId") String repoId,
|
@RequestParam(value = "repoId") String repoId,
|
||||||
|
@RequestParam(value = "interfaceId") String interfaceId,
|
||||||
@RequestParam(value = "jobId") String jobId,
|
@RequestParam(value = "jobId") String jobId,
|
||||||
@RequestParam(value = "issuerEmail") String issuerEmail,
|
@RequestParam(value = "issuerEmail") String issuerEmail,
|
||||||
@RequestParam(value = "isUpdate") boolean isUpdate,
|
@RequestParam(value = "isUpdate") boolean isUpdate,
|
||||||
|
@ -121,7 +121,7 @@ public class ValidatorController {
|
||||||
@RequestParam(value = "scoreUsage") int scoreUsage,
|
@RequestParam(value = "scoreUsage") int scoreUsage,
|
||||||
@RequestParam(value = "scoreContent") int scoreContent) throws Exception {
|
@RequestParam(value = "scoreContent") int scoreContent) throws Exception {
|
||||||
|
|
||||||
emailUtils.sendUponJobCompletion(repoId,interfaceId,scoreUsage,scoreContent,isSuccess,isUpdate,issuerEmail, jobId);
|
validatorService.onComplete(repoId, interfaceId, jobId, issuerEmail, isUpdate, isSuccess, scoreUsage, scoreContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.domain;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class AggregationDetails{
|
|
||||||
|
|
||||||
|
|
||||||
private String aggregationStage;
|
|
||||||
private Date date;
|
|
||||||
private int numberOfRecords;
|
|
||||||
private String collectionMode;
|
|
||||||
private Boolean indexedVersion;
|
|
||||||
|
|
||||||
public AggregationDetails() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAggregationStage() {
|
|
||||||
return aggregationStage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCollectionMode() {
|
|
||||||
return collectionMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCollectionMode(String collectionMode) {
|
|
||||||
this.collectionMode = collectionMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAggregationStage(String aggregationStage) {
|
|
||||||
this.aggregationStage = aggregationStage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getDate() {
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDate(Date date) {
|
|
||||||
this.date = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNumberOfRecords() {
|
|
||||||
return numberOfRecords;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNumberOfRecords(int numberOfRecords) {
|
|
||||||
this.numberOfRecords = numberOfRecords;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getYear() {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTime(getDate());
|
|
||||||
return String.valueOf(calendar.get(Calendar.YEAR));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getIndexedVersion() {
|
|
||||||
return indexedVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIndexedVersion(Boolean indexedVersion) {
|
|
||||||
this.indexedVersion = indexedVersion;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
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() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,32 +1,34 @@
|
||||||
package eu.dnetlib.repo.manager.domain;
|
package eu.dnetlib.repo.manager.domain;
|
||||||
|
|
||||||
|
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CollectionMonitorSummary {
|
public class CollectionMonitorSummary {
|
||||||
private List<AggregationDetails> aggregationDetails;
|
private List<AggregationInfo> aggregationInfo;
|
||||||
|
|
||||||
private AggregationDetails lastIndexedVersion;
|
private AggregationInfo lastIndexedVersion;
|
||||||
|
|
||||||
public CollectionMonitorSummary(){}
|
public CollectionMonitorSummary(){}
|
||||||
|
|
||||||
public CollectionMonitorSummary(List<AggregationDetails> aggregationDetails, AggregationDetails lastIndexedVersion) {
|
public CollectionMonitorSummary(List<AggregationInfo> aggregationInfo, AggregationInfo lastIndexedVersion) {
|
||||||
this.aggregationDetails = aggregationDetails;
|
this.aggregationInfo = aggregationInfo;
|
||||||
this.lastIndexedVersion = lastIndexedVersion;
|
this.lastIndexedVersion = lastIndexedVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AggregationDetails> getAggregationDetails() {
|
public List<AggregationInfo> getAggregationInfo() {
|
||||||
return aggregationDetails;
|
return aggregationInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAggregationDetails(List<AggregationDetails> aggregationDetails) {
|
public void setAggregationInfo(List<AggregationInfo> aggregationInfo) {
|
||||||
this.aggregationDetails = aggregationDetails;
|
this.aggregationInfo = aggregationInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AggregationDetails getLastIndexedVersion() {
|
public AggregationInfo getLastIndexedVersion() {
|
||||||
return lastIndexedVersion;
|
return lastIndexedVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastIndexedVersion(AggregationDetails lastIndexedVersion) {
|
public void setLastIndexedVersion(AggregationInfo lastIndexedVersion) {
|
||||||
this.lastIndexedVersion = lastIndexedVersion;
|
this.lastIndexedVersion = lastIndexedVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package eu.dnetlib.repo.manager.domain;
|
package eu.dnetlib.repo.manager.domain;
|
||||||
|
|
||||||
|
import javax.persistence.Transient;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.persistence.Transient;
|
|
||||||
|
|
||||||
public class DatasourceDetails {
|
public class DatasourceDetails {
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package eu.dnetlib.repo.manager.domain;
|
package eu.dnetlib.repo.manager.domain;
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.domain.Repository;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
package eu.dnetlib.repo.manager.domain;
|
||||||
|
|
||||||
|
import eu.dnetlib.repo.manager.domain.dto.InterfaceComplianceRequestDTO;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.IdClass;
|
||||||
|
import javax.persistence.Transient;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@IdClass(InterfaceComplianceRequestId.class)
|
||||||
|
public class InterfaceComplianceRequest {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
String repositoryId;
|
||||||
|
@Id
|
||||||
|
String interfaceId;
|
||||||
|
String desiredCompatibilityLevel;
|
||||||
|
Date submissionDate;
|
||||||
|
|
||||||
|
public InterfaceComplianceRequest() {
|
||||||
|
this.submissionDate = new Date();
|
||||||
|
}
|
||||||
|
|
||||||
|
public InterfaceComplianceRequest(String repositoryId, String interfaceId, String desiredCompatibilityLevel) {
|
||||||
|
this.submissionDate = new Date();
|
||||||
|
this.repositoryId = repositoryId;
|
||||||
|
this.interfaceId = interfaceId;
|
||||||
|
this.desiredCompatibilityLevel = desiredCompatibilityLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static InterfaceComplianceRequest from(InterfaceComplianceRequestDTO dto) {
|
||||||
|
InterfaceComplianceRequest request = new InterfaceComplianceRequest();
|
||||||
|
request.setRepositoryId(dto.getRepositoryId());
|
||||||
|
request.setInterfaceId(dto.getInterfaceId());
|
||||||
|
if (dto.getSubmissionDate() != null) {
|
||||||
|
request.setSubmissionDate(dto.getSubmissionDate());
|
||||||
|
} else {
|
||||||
|
request.setSubmissionDate(new Date());
|
||||||
|
}
|
||||||
|
request.setDesiredCompatibilityLevel(dto.getDesiredCompatibilityLevel());
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
public InterfaceComplianceRequestId getId() {
|
||||||
|
InterfaceComplianceRequestId id = new InterfaceComplianceRequestId();
|
||||||
|
id.repositoryId = this.repositoryId;
|
||||||
|
id.interfaceId = this.interfaceId;
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRepositoryId() {
|
||||||
|
return repositoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRepositoryId(String repositoryId) {
|
||||||
|
this.repositoryId = repositoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInterfaceId() {
|
||||||
|
return interfaceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInterfaceId(String interfaceId) {
|
||||||
|
this.interfaceId = interfaceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDesiredCompatibilityLevel() {
|
||||||
|
return desiredCompatibilityLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDesiredCompatibilityLevel(String desiredCompatibilityLevel) {
|
||||||
|
this.desiredCompatibilityLevel = desiredCompatibilityLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getSubmissionDate() {
|
||||||
|
return submissionDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubmissionDate(Date submissionDate) {
|
||||||
|
this.submissionDate = submissionDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "InterfaceComplianceRequest{" +
|
||||||
|
"repositoryId='" + repositoryId + '\'' +
|
||||||
|
", interfaceId='" + interfaceId + '\'' +
|
||||||
|
", desiredCompatibilityLevel='" + desiredCompatibilityLevel + '\'' +
|
||||||
|
", submissionDate=" + submissionDate +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package eu.dnetlib.repo.manager.domain;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class InterfaceComplianceRequestId implements Serializable {
|
||||||
|
String repositoryId;
|
||||||
|
String interfaceId;
|
||||||
|
|
||||||
|
public String getRepositoryId() {
|
||||||
|
return repositoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRepositoryId(String repositoryId) {
|
||||||
|
this.repositoryId = repositoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInterfaceId() {
|
||||||
|
return interfaceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInterfaceId(String interfaceId) {
|
||||||
|
this.interfaceId = interfaceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static InterfaceComplianceRequestId of(String repositoryId, String interfaceId) {
|
||||||
|
InterfaceComplianceRequestId id = new InterfaceComplianceRequestId();
|
||||||
|
id.setRepositoryId(repositoryId);
|
||||||
|
id.setInterfaceId(interfaceId);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (!(o instanceof InterfaceComplianceRequestId)) return false;
|
||||||
|
|
||||||
|
InterfaceComplianceRequestId that = (InterfaceComplianceRequestId) o;
|
||||||
|
|
||||||
|
if (getRepositoryId() != null ? !getRepositoryId().equals(that.getRepositoryId()) : that.getRepositoryId() != null)
|
||||||
|
return false;
|
||||||
|
return getInterfaceId() != null ? getInterfaceId().equals(that.getInterfaceId()) : that.getInterfaceId() == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = getRepositoryId() != null ? getRepositoryId().hashCode() : 0;
|
||||||
|
result = 31 * result + (getInterfaceId() != null ? getInterfaceId().hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,7 +3,8 @@ package eu.dnetlib.repo.manager.domain;
|
||||||
import eu.dnetlib.domain.data.DataCollectionType;
|
import eu.dnetlib.domain.data.DataCollectionType;
|
||||||
import eu.dnetlib.domain.data.PiwikInfo;
|
import eu.dnetlib.domain.data.PiwikInfo;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The domain object for the Repository resource data structure
|
* The domain object for the Repository resource data structure
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package eu.dnetlib.repo.manager.domain.dto;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class InterfaceComplianceRequestDTO {
|
||||||
|
|
||||||
|
String repositoryId;
|
||||||
|
String interfaceId;
|
||||||
|
String desiredCompatibilityLevel;
|
||||||
|
Date submissionDate;
|
||||||
|
|
||||||
|
public InterfaceComplianceRequestDTO() {
|
||||||
|
// no-arg constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRepositoryId() {
|
||||||
|
return repositoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRepositoryId(String repositoryId) {
|
||||||
|
this.repositoryId = repositoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInterfaceId() {
|
||||||
|
return interfaceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInterfaceId(String interfaceId) {
|
||||||
|
this.interfaceId = interfaceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDesiredCompatibilityLevel() {
|
||||||
|
return desiredCompatibilityLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDesiredCompatibilityLevel(String desiredCompatibilityLevel) {
|
||||||
|
this.desiredCompatibilityLevel = desiredCompatibilityLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getSubmissionDate() {
|
||||||
|
return submissionDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubmissionDate(Date submissionDate) {
|
||||||
|
this.submissionDate = submissionDate;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package eu.dnetlib.repo.manager.exception;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
|
||||||
|
@ResponseStatus(HttpStatus.CONFLICT)
|
||||||
|
public class ResourceConflictException extends RuntimeException {
|
||||||
|
|
||||||
|
public ResourceConflictException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package eu.dnetlib.repo.manager.repository;
|
||||||
|
|
||||||
|
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequest;
|
||||||
|
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequestId;
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface InterfaceComplianceRequestsRepository extends CrudRepository<InterfaceComplianceRequest, InterfaceComplianceRequestId> {
|
||||||
|
|
||||||
|
Set<InterfaceComplianceRequest> findAllBySubmissionDateBefore(Date submittedBefore);
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
|
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
|
||||||
|
import org.json.JSONException;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface AggregationService {
|
||||||
|
|
||||||
|
<T extends AggregationInfo> List<T> getRepositoryAggregations(String id) throws JSONException;
|
||||||
|
|
||||||
|
<T extends AggregationInfo> List<T> getRepositoryAggregations(String id, int from, int size) throws JSONException;
|
||||||
|
|
||||||
|
<T extends AggregationInfo> Map<String, List<T>> getRepositoryAggregationsByYear(String id) throws JSONException;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
|
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
|
||||||
|
import eu.dnetlib.repo.manager.domain.AggregationHistoryResponse;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
import org.springframework.web.util.UriComponents;
|
||||||
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static eu.dnetlib.repo.manager.utils.DateUtils.getYear;
|
||||||
|
|
||||||
|
@Service("aggregationService")
|
||||||
|
public class AggregationServiceImpl implements AggregationService {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(AggregationServiceImpl.class);
|
||||||
|
|
||||||
|
|
||||||
|
@Value("${services.provide.clients.dsm}")
|
||||||
|
private String baseAddress;
|
||||||
|
|
||||||
|
private final RestTemplate restTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
public AggregationServiceImpl(RestTemplate restTemplate) {
|
||||||
|
this.restTemplate = restTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends AggregationInfo> List<T> getRepositoryAggregations(String id) {
|
||||||
|
|
||||||
|
logger.debug("Retrieving aggregations for repository with id : " + id);
|
||||||
|
UriComponents uriComponents = getAggregationHistory(id);
|
||||||
|
|
||||||
|
AggregationHistoryResponse rs = restTemplate.getForObject(uriComponents.toUri(), AggregationHistoryResponse.class);
|
||||||
|
|
||||||
|
return rs != null ? (List<T>) rs.getAggregationInfo() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends AggregationInfo> List<T> getRepositoryAggregations(String id, int from, int size) {
|
||||||
|
|
||||||
|
List<T> res = getRepositoryAggregations(id);
|
||||||
|
|
||||||
|
return res.subList(from, Math.min(from + size, res.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends AggregationInfo> Map<String, List<T>> getRepositoryAggregationsByYear(String id) {
|
||||||
|
logger.debug("Retrieving aggregations (by year) for repository with id : " + id);
|
||||||
|
|
||||||
|
List<T> aggregationHistory = getRepositoryAggregations(id);
|
||||||
|
|
||||||
|
return aggregationHistory.isEmpty() ? new HashMap<>() : createYearMap(aggregationHistory);
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T extends AggregationInfo> Map<String, List<T>> createYearMap(List<T> aggregationHistory) {
|
||||||
|
|
||||||
|
return aggregationHistory.stream()
|
||||||
|
.sorted(Comparator.comparing(AggregationInfo::getDate).reversed())
|
||||||
|
.collect(Collectors.groupingBy(item -> getYear(item.getDate())));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private UriComponents getAggregationHistory(String repoId) {
|
||||||
|
return UriComponentsBuilder
|
||||||
|
.fromHttpUrl(baseAddress + "/ds/aggregationhistory/")
|
||||||
|
.path(repoId)
|
||||||
|
.build().expand(repoId).encode();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package eu.dnetlib.repo.manager.service;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
|
||||||
import eu.dnetlib.repo.manager.domain.Term;
|
import eu.dnetlib.repo.manager.domain.Term;
|
||||||
import eu.dnetlib.repo.manager.domain.broker.*;
|
import eu.dnetlib.repo.manager.domain.broker.*;
|
||||||
|
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,15 @@ package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
|
||||||
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
|
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
|
||||||
import eu.dnetlib.repo.manager.domain.Term;
|
import eu.dnetlib.repo.manager.domain.Term;
|
||||||
import eu.dnetlib.repo.manager.domain.Tuple;
|
import eu.dnetlib.repo.manager.domain.Tuple;
|
||||||
import eu.dnetlib.repo.manager.domain.broker.*;
|
import eu.dnetlib.repo.manager.domain.broker.*;
|
||||||
|
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||||
import org.apache.commons.lang.NotImplementedException;
|
import org.apache.commons.lang.NotImplementedException;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.ParameterizedTypeReference;
|
import org.springframework.core.ParameterizedTypeReference;
|
||||||
|
@ -26,7 +28,10 @@ import javax.annotation.PostConstruct;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Service("brokerService")
|
@Service("brokerService")
|
||||||
public class BrokerServiceImpl implements BrokerService {
|
public class BrokerServiceImpl implements BrokerService {
|
||||||
|
@ -40,15 +45,14 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
@Value("${services.provide.topic_types.url}")
|
@Value("${services.provide.topic_types.url}")
|
||||||
private String topicsURL;
|
private String topicsURL;
|
||||||
|
|
||||||
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger
|
private static final Logger logger = LoggerFactory.getLogger(BrokerServiceImpl.class);
|
||||||
.getLogger(BrokerServiceImpl.class);
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RestTemplate restTemplate;
|
RestTemplate restTemplate;
|
||||||
|
|
||||||
private HttpHeaders httpHeaders;
|
private HttpHeaders httpHeaders;
|
||||||
|
|
||||||
private HashMap<String, Term> topics = new HashMap<String, Term>();
|
private HashMap<String, Term> topics = new HashMap<>();
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void initDnetTopicsMap() {
|
private void initDnetTopicsMap() {
|
||||||
|
@ -56,14 +60,14 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
httpHeaders = new HttpHeaders();
|
httpHeaders = new HttpHeaders();
|
||||||
httpHeaders.set("Content-Type", "application/json");
|
httpHeaders.set("Content-Type", "application/json");
|
||||||
|
|
||||||
LOGGER.debug("Init dnet topics!");
|
logger.debug("Init dnet topics!");
|
||||||
try (InputStream is = new URL(topicsURL).openStream()) {
|
try (InputStream is = new URL(topicsURL).openStream()) {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
JsonNode root = mapper.readTree(is);
|
JsonNode root = mapper.readTree(is);
|
||||||
for (JsonNode term : root.path("terms"))
|
for (JsonNode term : root.path("terms"))
|
||||||
topics.put(term.path("code").textValue(), parseTerm(term));
|
topics.put(term.path("code").textValue(), parseTerm(term));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error("Exception on initDnetTopicsMap", e);
|
logger.error("Exception on initDnetTopicsMap", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +93,7 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
// ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
|
// ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
|
||||||
// }
|
// }
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Exception on getDatasourcesOfUser", e);
|
logger.error("Exception on getDatasourcesOfUser", e);
|
||||||
}
|
}
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
System.out.println("Getting datasources of user in " + (end - start) + "ms");
|
System.out.println("Getting datasources of user in " + (end - start) + "ms");
|
||||||
|
@ -121,7 +125,7 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
@Override
|
@Override
|
||||||
public EventsPage advancedShowEvents(String page,
|
public EventsPage advancedShowEvents(String page,
|
||||||
String size,
|
String size,
|
||||||
AdvQueryObject advQueryObject) throws BrokerException, JSONException, IOException {
|
AdvQueryObject advQueryObject) throws BrokerException {
|
||||||
|
|
||||||
final String service = "/events/{page}/{pageSize}";
|
final String service = "/events/{page}/{pageSize}";
|
||||||
|
|
||||||
|
@ -156,7 +160,7 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
for (RepositorySnippet repo : repositories) {
|
for (RepositorySnippet repo : repositories) {
|
||||||
BrowseEntry temp = new BrowseEntry();
|
BrowseEntry temp = new BrowseEntry();
|
||||||
temp.setValue(repo.getOfficialname());
|
temp.setValue(repo.getOfficialname());
|
||||||
temp.setSize(new Long(0));
|
temp.setSize(0L);
|
||||||
for (BrowseEntry e : getTopicsForDatasource(repo.getOfficialname())) {
|
for (BrowseEntry e : getTopicsForDatasource(repo.getOfficialname())) {
|
||||||
temp.setSize(temp.getSize() + e.getSize());
|
temp.setSize(temp.getSize() + e.getSize());
|
||||||
}
|
}
|
||||||
|
@ -165,12 +169,7 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort the collection by the second field of the tuple which is size
|
// sort the collection by the second field of the tuple which is size
|
||||||
Collections.sort(entries, new Comparator<Tuple<BrowseEntry, String>>() {
|
entries.sort((e1, e2) -> (int) (e2.getFirst().getSize() - e1.getFirst().getSize()));
|
||||||
@Override
|
|
||||||
public int compare(Tuple<BrowseEntry, String> e1, Tuple<BrowseEntry, String> e2) {
|
|
||||||
return (int) (e2.getFirst().getSize().longValue() - e1.getFirst().getSize().longValue());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
long stop = System.currentTimeMillis();
|
long stop = System.currentTimeMillis();
|
||||||
System.out.println("getDatasourcesOfUserType returned in " + (stop - start) + "ms ");
|
System.out.println("getDatasourcesOfUserType returned in " + (stop - start) + "ms ");
|
||||||
|
|
||||||
|
@ -213,7 +212,7 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
||||||
.queryParam("email", userEmail);
|
.queryParam("email", userEmail);
|
||||||
|
|
||||||
LOGGER.debug(builder.build().encode().toUri());
|
logger.debug("{}", builder.build().encode().toUri());
|
||||||
ResponseEntity<Map<String, List<SimpleSubscriptionDesc>>> resp;
|
ResponseEntity<Map<String, List<SimpleSubscriptionDesc>>> resp;
|
||||||
try {
|
try {
|
||||||
resp = restTemplate.exchange(
|
resp = restTemplate.exchange(
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
package eu.dnetlib.repo.manager.service;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.domain.*;
|
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
|
||||||
|
import eu.dnetlib.repo.manager.domain.MetricsInfo;
|
||||||
|
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
|
||||||
|
import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo;
|
||||||
import eu.dnetlib.repo.manager.domain.broker.BrowseEntry;
|
import eu.dnetlib.repo.manager.domain.broker.BrowseEntry;
|
||||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||||
import org.apache.log4j.Logger;
|
import eu.dnetlib.repo.manager.utils.DateUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -14,11 +19,14 @@ import java.util.List;
|
||||||
@Service("dashboardService")
|
@Service("dashboardService")
|
||||||
public class DashboardServiceImpl implements DashboardService {
|
public class DashboardServiceImpl implements DashboardService {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(DashboardServiceImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(DashboardServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RepositoryService repositoryService;
|
private RepositoryService repositoryService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AggregationService aggregationService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BrokerService brokerService;
|
private BrokerService brokerService;
|
||||||
|
|
||||||
|
@ -30,7 +38,6 @@ public class DashboardServiceImpl implements DashboardService {
|
||||||
List<RepositorySummaryInfo> repositorySummaryInfoList = new ArrayList<>();
|
List<RepositorySummaryInfo> repositorySummaryInfoList = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
List<RepositorySnippet> repositoriesOfUser = repositoryService.getRepositoriesSnippetsOfUser(userEmail, page, size);
|
List<RepositorySnippet> repositoriesOfUser = repositoryService.getRepositoriesSnippetsOfUser(userEmail, page, size);
|
||||||
for (RepositorySnippet repository : repositoriesOfUser) {
|
for (RepositorySnippet repository : repositoriesOfUser) {
|
||||||
RepositorySummaryInfo repositorySummaryInfo = new RepositorySummaryInfo();
|
RepositorySummaryInfo repositorySummaryInfo = new RepositorySummaryInfo();
|
||||||
|
@ -40,44 +47,37 @@ public class DashboardServiceImpl implements DashboardService {
|
||||||
|
|
||||||
//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 positive that we will find an indexed version there?
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
List<AggregationDetails> aggregationDetailsList = repositoryService.getRepositoryAggregations(repository.getId(), 0, 20);
|
List<AggregationInfo> aggregationInfoList = aggregationService.getRepositoryAggregations(repository.getId(), 0, 20);
|
||||||
for (AggregationDetails aggregationDetails : aggregationDetailsList) {
|
for (AggregationInfo aggregationInfo : aggregationInfoList) {
|
||||||
if (aggregationDetails.getIndexedVersion()) {
|
if (aggregationInfo.isIndexedVersion()) {
|
||||||
repositorySummaryInfo.setRecordsCollected(aggregationDetails.getNumberOfRecords());
|
repositorySummaryInfo.setRecordsCollected(aggregationInfo.getNumberOfRecords());
|
||||||
repositorySummaryInfo.setLastIndexedVersion(aggregationDetails.getDate());
|
repositorySummaryInfo.setLastIndexedVersion(DateUtils.toDate(aggregationInfo.getDate()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
|
|
||||||
System.out.println("Got repo aggregations in " + (end - start) + "ms");
|
System.out.println("Got repo aggregations in " + (end - start) + "ms");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
MetricsInfo metricsInfo = repositoryService.getMetricsInfoForRepository(repository.getId());
|
MetricsInfo metricsInfo = repositoryService.getMetricsInfoForRepository(repository.getId());
|
||||||
repositorySummaryInfo.setTotalDownloads(metricsInfo.getMetricsNumbers().getTotalDownloads());
|
repositorySummaryInfo.setTotalDownloads(metricsInfo.getMetricsNumbers().getTotalDownloads());
|
||||||
repositorySummaryInfo.setTotalViews(metricsInfo.getMetricsNumbers().getTotalViews());
|
repositorySummaryInfo.setTotalViews(metricsInfo.getMetricsNumbers().getTotalViews());
|
||||||
|
|
||||||
} catch (RepositoryServiceException e) {
|
} catch (RepositoryServiceException e) {
|
||||||
logger.error("Exception getting metrics info for repository: " + repository.getId(), e);
|
logger.error("Exception getting metrics info for repository: " + repository.getId(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
List<BrowseEntry> events = brokerService.getTopicsForDatasource(repository.getOfficialname());
|
List<BrowseEntry> events = brokerService.getTopicsForDatasource(repository.getOfficialname());
|
||||||
Long totalEvents = 0L;
|
Long totalEvents = 0L;
|
||||||
for (BrowseEntry browseEntry : events)
|
for (BrowseEntry browseEntry : events)
|
||||||
totalEvents += browseEntry.getSize();
|
totalEvents += browseEntry.getSize();
|
||||||
repositorySummaryInfo.setEnrichmentEvents(totalEvents);
|
repositorySummaryInfo.setEnrichmentEvents(totalEvents);
|
||||||
|
|
||||||
|
|
||||||
} catch (BrokerException e) {
|
} catch (BrokerException e) {
|
||||||
logger.error("Exception getting broker events for repository: " + repository.getId(), e);
|
logger.error("Exception getting broker events for repository: " + repository.getId(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
repositorySummaryInfoList.add(repositorySummaryInfo);
|
repositorySummaryInfoList.add(repositorySummaryInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Something baad happened!", e);
|
logger.error("Something baad happened!", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,93 +1,103 @@
|
||||||
package eu.dnetlib.repo.manager.service;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import eu.dnetlib.domain.data.PiwikInfo;
|
import eu.dnetlib.domain.data.PiwikInfo;
|
||||||
|
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||||
|
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequest;
|
||||||
import eu.dnetlib.repo.manager.domain.Repository;
|
import eu.dnetlib.repo.manager.domain.Repository;
|
||||||
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
|
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
|
||||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface EmailUtils {
|
public interface EmailUtils {
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception;
|
void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception;
|
void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo) throws Exception;
|
void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendUserMetricsEnabled(PiwikInfo piwikInfo) throws Exception;
|
void sendUserMetricsEnabled(PiwikInfo piwikInfo);
|
||||||
|
|
||||||
/****USER REGISTRATION REQUEST EMAILS****/
|
/****USER REGISTRATION REQUEST EMAILS****/
|
||||||
@Async
|
@Async
|
||||||
void sendAdminRegistrationEmail(Repository repository, Authentication authentication) throws Exception;
|
void sendAdminRegistrationEmail(Repository repository, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception;
|
void sendUserRegistrationEmail(Repository repository, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication);
|
||||||
|
|
||||||
/****SUCCESSFUL REGISTRATION RESULTS EMAILS****/
|
/****SUCCESSFUL REGISTRATION RESULTS EMAILS****/
|
||||||
@Async
|
@Async
|
||||||
void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
/****FAILURE REGISTRATION RESULTS EMAILS****/
|
/****FAILURE REGISTRATION RESULTS EMAILS****/
|
||||||
@Async
|
@Async
|
||||||
void sendUserRegistrationResultsFailureEmail(String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
/****SUCCESSFUL UPDATE RESULTS EMAILS****/
|
/****SUCCESSFUL UPDATE RESULTS EMAILS****/
|
||||||
@Async
|
@Async
|
||||||
void sendUserUpdateResultsSuccessEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
void sendUserUpdateResultsSuccessEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
/****FAILURE UPDATE RESULTS EMAILS****/
|
/****FAILURE UPDATE RESULTS EMAILS****/
|
||||||
@Async
|
@Async
|
||||||
void sendUserUpdateResultsFailureEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
void sendUserUpdateResultsFailureEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
|
/****FAILURE UPDATE INTERFACE COMPLIANCE****/
|
||||||
|
@Async
|
||||||
|
void sendUserUpdateInterfaceComplianceFailure(List<String> emails, Repository repository, RepositoryInterface repositoryInterface, InterfaceComplianceRequest request);
|
||||||
|
|
||||||
|
@Async
|
||||||
|
void sendAdminUpdateInterfaceComplianceFailure(Repository repository, RepositoryInterface repositoryInterface, InterfaceComplianceRequest request);
|
||||||
|
|
||||||
/****VALIDATION OF CONTENT PROVIDER EMAILS****/
|
/****VALIDATION OF CONTENT PROVIDER EMAILS****/
|
||||||
@Async
|
@Async
|
||||||
void sendUserValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
void sendUserValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendAdminValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
void sendAdminValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
/****GENERAL FAILURE OF VALIDATOR****/
|
/****GENERAL FAILURE OF VALIDATOR****/
|
||||||
@Async
|
@Async
|
||||||
void sendAdminGeneralFailure(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
void sendAdminGeneralFailure(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendAdminUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) throws Exception;
|
void sendAdminUpdateRepositoryInfoEmail(Repository repository, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) throws Exception;
|
void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception;
|
void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendUponJobCompletion(String repoId,
|
void sendUponJobCompletion(String repoId,
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
package eu.dnetlib.repo.manager.service;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import eu.dnetlib.domain.data.PiwikInfo;
|
import eu.dnetlib.domain.data.PiwikInfo;
|
||||||
|
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||||
|
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequest;
|
||||||
import eu.dnetlib.repo.manager.domain.Repository;
|
import eu.dnetlib.repo.manager.domain.Repository;
|
||||||
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
|
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
|
||||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
|
||||||
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
||||||
import eu.dnetlib.utils.MailLibrary;
|
import eu.dnetlib.utils.MailLibrary;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
|
@ -21,7 +23,7 @@ import java.util.stream.Collectors;
|
||||||
@Component("emailUtils")
|
@Component("emailUtils")
|
||||||
public class EmailUtilsImpl implements EmailUtils {
|
public class EmailUtilsImpl implements EmailUtils {
|
||||||
|
|
||||||
private final static Logger LOGGER = Logger.getLogger(EmailUtilsImpl.class);
|
private final static Logger logger = LoggerFactory.getLogger(EmailUtilsImpl.class);
|
||||||
|
|
||||||
private final MailLibrary mailLibrary;
|
private final MailLibrary mailLibrary;
|
||||||
private final RepositoryService repositoryService;
|
private final RepositoryService repositoryService;
|
||||||
|
@ -45,33 +47,32 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception {
|
public void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String subject = "[OpenAIRE-Usage Statistics] New request to enable usage statistics";
|
String subject = "[OpenAIRE-Usage Statistics] New request to enable usage statistics";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"we have received a request to enable the OpenAIRE usage statistics for the following repository \n" +
|
"we have received a request to enable the OpenAIRE usage statistics for the following repository \n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
|
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
|
||||||
"Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" +
|
"Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" +
|
||||||
"Matomo ID - " + piwikInfo.getSiteId() + "\n" +
|
"Matomo ID - " + piwikInfo.getSiteId() + "\n" +
|
||||||
"Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" +
|
"Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"For more information about this request, go here: \n" +
|
"For more information about this request, go here: \n" +
|
||||||
this.baseUrl + "/admin/metrics";
|
this.baseUrl + "/admin/metrics";
|
||||||
message = createAdminMail(message);
|
message = createAdminMail(message);
|
||||||
|
|
||||||
this.sendMail(this.usageStatsAdminEmail, subject, message);
|
this.sendMail(this.usageStatsAdminEmail, subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending request to enable metrics email to administrator: " + this.usageStatsAdminEmail, e);
|
logger.error("Error while sending request to enable metrics email to administrator: " + this.usageStatsAdminEmail, e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception {
|
public void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String subject = "[OpenAIRE-Usage Statistics] Your request to enable usage statistics";
|
String subject = "[OpenAIRE-Usage Statistics] Your request to enable usage statistics";
|
||||||
|
@ -102,37 +103,35 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
this.sendMail(piwikInfo.getRequestorEmail(), subject, message);
|
this.sendMail(piwikInfo.getRequestorEmail(), subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending request to enable metrics email to user: " + piwikInfo.getRequestorEmail(), e);
|
logger.error("Error while sending request to enable metrics email to user: " + piwikInfo.getRequestorEmail(), e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo) throws Exception {
|
public void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String subject = "[OpenAIRE-Usage Statistics] Usage statistics have been enabled";
|
String subject = "[OpenAIRE-Usage Statistics] Usage statistics have been enabled";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"The installation and configuration of OpenAIRE's tracking code for the following repository " +
|
"The installation and configuration of OpenAIRE's tracking code for the following repository " +
|
||||||
"has been completed and validated and the usage statistics have been enabled in OpenAIRE.\n" +
|
"has been completed and validated and the usage statistics have been enabled in OpenAIRE.\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
|
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
|
||||||
"Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" +
|
"Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" +
|
||||||
"Piwik ID - " + piwikInfo.getSiteId() + "\n" +
|
"Piwik ID - " + piwikInfo.getSiteId() + "\n" +
|
||||||
"Authentication token - " + piwikInfo.getAuthenticationToken();
|
"Authentication token - " + piwikInfo.getAuthenticationToken();
|
||||||
message = createAdminMail(message);
|
message = createAdminMail(message);
|
||||||
|
|
||||||
this.sendMail(this.usageStatsAdminEmail, subject, message);
|
this.sendMail(this.usageStatsAdminEmail, subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending metrics enabled notification email to administator: " + this.usageStatsAdminEmail, e);
|
logger.error("Error while sending metrics enabled notification email to administator: " + this.usageStatsAdminEmail, e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUserMetricsEnabled(PiwikInfo piwikInfo) throws Exception {
|
public void sendUserMetricsEnabled(PiwikInfo piwikInfo) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String subject = "[OpenAIRE-Usage Statistics] Usage statistics have been enabled";
|
String subject = "[OpenAIRE-Usage Statistics] Usage statistics have been enabled";
|
||||||
|
@ -154,70 +153,67 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
this.sendMail(piwikInfo.getRequestorEmail(), subject, message);
|
this.sendMail(piwikInfo.getRequestorEmail(), subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending metrics enabled notification email to user: " + piwikInfo.getRequestorEmail(), e);
|
logger.error("Error while sending metrics enabled notification email to user: " + piwikInfo.getRequestorEmail(), e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAdminRegistrationEmail(Repository repository, Authentication authentication) throws Exception {
|
public void sendAdminRegistrationEmail(Repository repository, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE content provider registration for " +
|
String subject = "OpenAIRE content provider registration for " +
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"We received a request to register the " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]" +
|
"We received a request to register the " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]" +
|
||||||
" to the OpenAIRE compliant list of content providers. " +
|
" to the OpenAIRE compliant list of content providers. " +
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
"User Contact: " + authentication.getName() + " (" + ((OIDCAuthenticationToken) authentication).getUserInfo().getEmail() + ")" +
|
"User Contact: " + authentication.getName() + " (" + ((OIDCAuthenticationToken) authentication).getUserInfo().getEmail() + ")" +
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
"Please do not reply to this message\n" +
|
"Please do not reply to this message\n" +
|
||||||
"This message has been generated automatically.";
|
"This message has been generated automatically.";
|
||||||
message = createAdminMail(message);
|
message = createAdminMail(message);
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
this.sendMail(this.provideAdminEmail, subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending registration notification email to the administrator", e);
|
logger.error("Error while sending registration notification email to the administrator", e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception {
|
public void sendUserRegistrationEmail(Repository repository, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE content provider registration for " +
|
String subject = "OpenAIRE content provider registration for " +
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"We received a request to register the " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]" +
|
"We received a request to register the " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]" +
|
||||||
" to the OpenAIRE compliant list of content providers. " +
|
" to the OpenAIRE compliant list of content providers. " +
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
"Please do not reply to this message\n" +
|
"Please do not reply to this message\n" +
|
||||||
"This message has been generated automatically.\n\n" +
|
"This message has been generated automatically.\n\n" +
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
||||||
message = createUserMail(message, authentication);
|
message = createUserMail(message, authentication);
|
||||||
|
|
||||||
this.sendMail(repository.getRegisteredby(), subject, message);
|
this.sendMail(repository.getRegisteredby(), subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
logger.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
public void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE new interface registration request started for " +
|
String subject = "OpenAIRE new interface registration request started for " +
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"We received a request to add the following interface: \n\n" +
|
"We received a request to add the following interface: \n\n" +
|
||||||
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
|
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
|
||||||
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
||||||
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
|
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
|
||||||
"to " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
|
"to " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
|
||||||
|
|
||||||
if (comment != null)
|
if (comment != null)
|
||||||
message += "\nThe users comment was '" + comment + "'\n";
|
message += "\nThe users comment was '" + comment + "'\n";
|
||||||
|
@ -234,22 +230,21 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
this.sendMail(this.provideAdminEmail, subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending registration of interface notification email to the administrator", e);
|
logger.error("Error while sending registration of interface notification email to the administrator", e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
public void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE new interface registration request started for " +
|
String subject = "OpenAIRE new interface registration request started for " +
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||||
String message =
|
String message =
|
||||||
"We received a request to add the following interface: \n\n" +
|
"We received a request to add the following interface: \n\n" +
|
||||||
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
|
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
|
||||||
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
||||||
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
|
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
|
||||||
"to " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
|
"to " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
|
||||||
|
|
||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
message += "\n Your comment was '" + comment + "'\n";
|
message += "\n Your comment was '" + comment + "'\n";
|
||||||
|
@ -265,362 +260,404 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
this.sendMail(repository.getRegisteredby(), subject, message);
|
this.sendMail(repository.getRegisteredby(), subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending registration of interface notification email to user: " + repository.getRegisteredby(), e);
|
logger.error("Error while sending registration of interface notification email to user: " + repository.getRegisteredby(), e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
public void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE new interface registration request - results (success) for " +
|
String subject = "OpenAIRE new interface registration request - results (success) for " +
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
||||||
" was successful and the datasource type \""+ repository.getEoscDatasourceType() + "\" will be prepared for aggregation in OpenAIRE."+
|
" was successful and the datasource type \"" + repository.getEoscDatasourceType() + "\" will be prepared for aggregation in OpenAIRE." +
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
"Please note that it usually takes about 3-4 weeks until a data source is indexed and it’s metadata visible on openaire.eu.\n\n" +
|
"Please note that it usually takes about 3-4 weeks until a data source is indexed and it's metadata visible on openaire.eu.\n\n" +
|
||||||
"Registration identifier in OpenAIRE: "+ repository.getNamespaceprefix()+
|
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
||||||
"\nOfficial Name:" + repository.getOfficialname() +
|
"\nOfficial Name:" + repository.getOfficialname() +
|
||||||
"\n\nBase URL: "+ repositoryInterface.getBaseurl() +
|
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
||||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||||
"\n\nGuidelines: "+ repositoryInterface.getCompatibilityOverride() +
|
"\n\nGuidelines: " + repositoryInterface.getCompatibilityOverride() +
|
||||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||||
"\n\n\nPlease do not reply to this email\n"+
|
"\n\n\nPlease do not reply to this email\n" +
|
||||||
"This message has been generated manually\n\n"+
|
"This message has been generated manually\n\n" +
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
||||||
message = createUserMail(message, authentication);
|
message = createUserMail(message, authentication);
|
||||||
|
|
||||||
this.sendMail(repository.getRegisteredby(), subject, message);
|
this.sendMail(repository.getRegisteredby(), subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
logger.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
public void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE new interface registration request - results (success) for " +
|
String subject = "OpenAIRE new interface registration request - results (success) for " +
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
||||||
" was successful and the datasource type \""+ repository.getEoscDatasourceType() + "\" will be prepared for aggregation in OpenAIRE."+
|
" was successful and the datasource type \"" + repository.getEoscDatasourceType() + "\" will be prepared for aggregation in OpenAIRE." +
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
"Please note that it usually takes about 3-4 weeks until a data source is indexed and it’s metadata visible on openaire.eu.\n\n" +
|
"Please note that it usually takes about 3-4 weeks until a data source is indexed and it's metadata visible on openaire.eu.\n\n" +
|
||||||
"Registration identifier in OpenAIRE: "+ repository.getNamespaceprefix()+
|
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
||||||
"\nOfficial Name:" + repository.getOfficialname() +
|
"\nOfficial Name:" + repository.getOfficialname() +
|
||||||
"\n\nBase URL: "+ repositoryInterface.getBaseurl() +
|
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
||||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||||
"\n\nGuidelines: "+ repositoryInterface.getCompatibilityOverride() +
|
"\n\nGuidelines: " + repositoryInterface.getCompatibilityOverride() +
|
||||||
"\n\nUser Contact:"+ issuerEmail +""+
|
"\n\nUser Contact:" + issuerEmail + "" +
|
||||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||||
"\n\n\nPlease do not reply to this email\n"+
|
"\n\n\nPlease do not reply to this email\n" +
|
||||||
"This message has been generated manually\n\n"+
|
"This message has been generated manually\n\n" +
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
||||||
message = createAdminMail(message);
|
message = createAdminMail(message);
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
this.sendMail(this.provideAdminEmail, subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
logger.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
public void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE new interface registration request - results (failure) for " +
|
String subject = "OpenAIRE new interface registration request - results (failure) for " +
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||||
String message =
|
String message =
|
||||||
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
||||||
" was not successful and the registration process was interrupted."+
|
" was not successful and the registration process was interrupted." +
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
"We will check what caused the problem and get back to you within a couple of days.\n\n" +
|
"We will check what caused the problem and get back to you within a couple of days.\n\n" +
|
||||||
"Registration identifier in OpenAIRE: "+ repository.getNamespaceprefix()+
|
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
||||||
"\nOfficial Name:" + repository.getOfficialname() +
|
"\nOfficial Name:" + repository.getOfficialname() +
|
||||||
"\n\nBase URL: "+ repositoryInterface.getBaseurl() +
|
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
||||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||||
"\n\nGuidelines: "+ repositoryInterface.getCompatibilityOverride() +
|
"\n\nGuidelines: " + repositoryInterface.getCompatibilityOverride() +
|
||||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||||
"\n\n\nPlease do not reply to this email\n"+
|
"\n\n\nPlease do not reply to this email\n" +
|
||||||
"This message has been generated manually\n\n"+
|
"This message has been generated manually\n\n" +
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
||||||
message = createUserMail(message, authentication);
|
message = createUserMail(message, authentication);
|
||||||
|
|
||||||
this.sendMail(repository.getRegisteredby(), subject, message);
|
this.sendMail(repository.getRegisteredby(), subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
logger.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
public void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE new interface registration request - results (failure) for " +
|
String subject = "OpenAIRE new interface registration request - results (failure) for " +
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
||||||
" was not successful and the registration process was interrupted."+
|
" was not successful and the registration process was interrupted." +
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
"We will check what caused the problem and get back to you within a couple of days.\n\n" +
|
"We will check what caused the problem and get back to you within a couple of days.\n\n" +
|
||||||
"Registration identifier in OpenAIRE: "+ repository.getNamespaceprefix()+
|
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
||||||
"\nOfficial Name:" + repository.getOfficialname() +
|
"\nOfficial Name:" + repository.getOfficialname() +
|
||||||
"\n\nBase URL: "+ repositoryInterface.getBaseurl() +
|
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
||||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||||
"\n\nGuidelines: "+ repositoryInterface.getCompatibilityOverride() +
|
"\n\nGuidelines: " + repositoryInterface.getCompatibilityOverride() +
|
||||||
"\n\nUser Contact:"+ issuerEmail +""+
|
"\n\nUser Contact:" + issuerEmail + "" +
|
||||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||||
"\n\n\nPlease do not reply to this email\n"+
|
"\n\n\nPlease do not reply to this email\n" +
|
||||||
"This message has been generated manually\n\n"+
|
"This message has been generated manually\n\n" +
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
||||||
message = createAdminMail(message);
|
message = createAdminMail(message);
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
this.sendMail(this.provideAdminEmail, subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
logger.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUserUpdateResultsSuccessEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
public void sendUserUpdateResultsSuccessEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE interface update request - results (success) for " +
|
String subject = "OpenAIRE interface update request - results (success) for " +
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"the compatibility test on [" + repository.getOfficialname()+"] has been successful\n\n" +
|
"the compatibility test on [" + repository.getOfficialname() + "] has been successful\n\n" +
|
||||||
"We will check your transmitted information and adjust the aggregation settings accordingly. Please note that it usually takes about 3-4 weeks until the changes are visible on openaire.eu."+"\n\n" +
|
"We will check your transmitted information and adjust the aggregation settings accordingly. Please note that it usually takes about 3-4 weeks until the changes are visible on openaire.eu." + "\n\n" +
|
||||||
"Registration identifier in OpenAIRE: "+ repository.getNamespaceprefix()+
|
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
||||||
"\nOfficial Name:" + repository.getOfficialname() +
|
"\nOfficial Name:" + repository.getOfficialname() +
|
||||||
"\n\nBase URL: "+ repositoryInterface.getBaseurl() +
|
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
||||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||||
"\n\nGuidelines: "+ repositoryInterface.getCompatibilityOverride() +
|
"\n\nGuidelines: " + repositoryInterface.getCompatibilityOverride() +
|
||||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||||
"\n\n\nPlease do not reply to this email\n"+
|
"\n\n\nPlease do not reply to this email\n" +
|
||||||
"This message has been generated manually\n\n"+
|
"This message has been generated manually\n\n" +
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
||||||
message = createUserMail(message, authentication);
|
message = createUserMail(message, authentication);
|
||||||
|
|
||||||
this.sendMail(issuer, subject, message);
|
this.sendMail(issuer, subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending registration notification email to the administrator", e);
|
logger.error("Error while sending registration notification email to the administrator", e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
public void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE interface update request - results (success) for " +
|
String subject = "OpenAIRE interface update request - results (success) for " +
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"the compatibility test on [" + repository.getOfficialname()+"] has been successful\n\n" +
|
"the compatibility test on [" + repository.getOfficialname() + "] has been successful\n\n" +
|
||||||
"We will check your transmitted information and adjust the aggregation settings accordingly. Please note that it usually takes about 3-4 weeks until the changes are visible on openaire.eu."+"\n\n" +
|
"We will check your transmitted information and adjust the aggregation settings accordingly. Please note that it usually takes about 3-4 weeks until the changes are visible on openaire.eu." + "\n\n" +
|
||||||
"Registration identifier in OpenAIRE: "+ repository.getNamespaceprefix()+
|
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
||||||
"\nOfficial Name:" + repository.getOfficialname() +
|
"\nOfficial Name:" + repository.getOfficialname() +
|
||||||
"\n\nBase URL: "+ repositoryInterface.getBaseurl() +
|
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
||||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||||
"\n\nGuidelines: "+ repositoryInterface.getCompatibilityOverride() +
|
"\n\nGuidelines: " + repositoryInterface.getCompatibilityOverride() +
|
||||||
"\n\nUser Contact:"+ issuerEmail +""+
|
"\n\nUser Contact:" + issuerEmail + "" +
|
||||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||||
"\n\n\nPlease do not reply to this email\n"+
|
"\n\n\nPlease do not reply to this email\n" +
|
||||||
"This message has been generated manually\n\n"+
|
"This message has been generated manually\n\n" +
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
||||||
message = createAdminMail(message);
|
message = createAdminMail(message);
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
this.sendMail(this.provideAdminEmail, subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending registration notification email to the administrator", e);
|
logger.error("Error while sending registration notification email to the administrator", e);
|
||||||
throw e;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUserUpdateResultsFailureEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
public void sendUserUpdateResultsFailureEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE interface update request - results (failure) for " +
|
String subject = "OpenAIRE interface update request - results (failure) for " +
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
||||||
" was not successful."+
|
" was not successful." +
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
"WWe will check your transmitted information to see what caused the problem and get back to you within a couple of days.\n\n" +
|
"WWe will check your transmitted information to see what caused the problem and get back to you within a couple of days.\n\n" +
|
||||||
"Registration identifier in OpenAIRE: "+ repository.getNamespaceprefix()+
|
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
||||||
"\nOfficial Name:" + repository.getOfficialname() +
|
"\nOfficial Name:" + repository.getOfficialname() +
|
||||||
"\n\nBase URL: "+ repositoryInterface.getBaseurl() +
|
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
||||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||||
"\n\nGuidelines: "+ repositoryInterface.getCompatibilityOverride() +
|
"\n\nGuidelines: " + repositoryInterface.getCompatibilityOverride() +
|
||||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||||
"\n\n\nPlease do not reply to this email\n"+
|
"\n\n\nPlease do not reply to this email\n" +
|
||||||
"This message has been generated manually\n\n"+
|
"This message has been generated manually\n\n" +
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
||||||
message = createUserMail(message, authentication);
|
message = createUserMail(message, authentication);
|
||||||
|
|
||||||
this.sendMail(issuer, subject, message);
|
this.sendMail(issuer, subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
logger.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
public void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE interface update request - results (failure) for " +
|
String subject = "OpenAIRE interface update request - results (failure) for " +
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
"the compatibility test on " + "[" + repository.getOfficialname() + "]" +
|
||||||
" was not successful."+
|
" was not successful." +
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
"WWe will check your transmitted information to see what caused the problem and get back to you within a couple of days.\n\n" +
|
"WWe will check your transmitted information to see what caused the problem and get back to you within a couple of days.\n\n" +
|
||||||
"Registration identifier in OpenAIRE: "+ repository.getNamespaceprefix()+
|
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
||||||
"\nOfficial Name:" + repository.getOfficialname() +
|
"\nOfficial Name:" + repository.getOfficialname() +
|
||||||
"\n\nBase URL: "+ repositoryInterface.getBaseurl() +
|
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
||||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||||
"\n\nGuidelines: "+ repositoryInterface.getCompatibilityOverride() +
|
"\n\nGuidelines: " + repositoryInterface.getCompatibilityOverride() +
|
||||||
"\n\nUser Contact:"+ issuerEmail +""+
|
"\n\nUser Contact:" + issuerEmail + "" +
|
||||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||||
"\n\n\nPlease do not reply to this email\n"+
|
"\n\n\nPlease do not reply to this email\n" +
|
||||||
"This message has been generated manually\n\n"+
|
"This message has been generated manually\n\n" +
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
||||||
message = createAdminMail(message);
|
message = createAdminMail(message);
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
this.sendMail(this.provideAdminEmail, subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
logger.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUserValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
public void sendUserUpdateInterfaceComplianceFailure(List<String> emails, Repository repository, RepositoryInterface repositoryInterface, InterfaceComplianceRequest request) {
|
||||||
|
try {
|
||||||
|
String subject = "OpenAIRE interface update compliance request - results (failure) for " +
|
||||||
|
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||||
|
|
||||||
|
String message =
|
||||||
|
"The request for changing the compatibility of " + "[" + repository.getOfficialname() + "]" +
|
||||||
|
" was not successful." +
|
||||||
|
"\n\n" +
|
||||||
|
|
||||||
|
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
||||||
|
"\nOfficial Name:" + repository.getOfficialname() +
|
||||||
|
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
||||||
|
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||||
|
"\n\nGuidelines: " + request.getDesiredCompatibilityLevel() +
|
||||||
|
"\n\n\nPlease do not reply to this email\n" +
|
||||||
|
"This message has been generated automatically\n\n" +
|
||||||
|
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
||||||
|
message = createRepoAdminsMail(message);
|
||||||
|
|
||||||
|
this.sendMail(emails, subject, message);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Notification email to repository admins failed.\nRepository: {}\nRequest: {}", repository, request, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendAdminUpdateInterfaceComplianceFailure(Repository repository, RepositoryInterface repositoryInterface, InterfaceComplianceRequest request) {
|
||||||
|
try {
|
||||||
|
String subject = "OpenAIRE interface update compliance request - results (failure) for " +
|
||||||
|
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||||
|
|
||||||
|
String message =
|
||||||
|
"The request for changing the compatibility of " + "[" + repository.getOfficialname() + "]" +
|
||||||
|
" was not successful." +
|
||||||
|
"\n\n" +
|
||||||
|
|
||||||
|
"Registration identifier in OpenAIRE: " + repository.getNamespaceprefix() +
|
||||||
|
"\nOfficial Name:" + repository.getOfficialname() +
|
||||||
|
"\n\nBase URL: " + repositoryInterface.getBaseurl() +
|
||||||
|
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||||
|
"\n\nGuidelines: " + request.getDesiredCompatibilityLevel() +
|
||||||
|
"\n\n\nPlease do not reply to this email\n" +
|
||||||
|
"This message has been generated automatically\n\n" +
|
||||||
|
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
||||||
|
message = createAdminMail(message);
|
||||||
|
|
||||||
|
this.sendMail(this.provideAdminEmail, subject, message);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendUserValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE validator - Test results ";
|
String subject = "OpenAIRE validator - Test results ";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"the validation request you have submitted has finished. You can retrieve the results by following this url: "+ valBaseUrl+"" + jobId+" .\n\n" +
|
"the validation request you have submitted has finished. You can retrieve the results by following this url: " + valBaseUrl + "" + jobId + " .\n\n" +
|
||||||
"Please do not reply to this message.\n" +
|
"Please do not reply to this message.\n" +
|
||||||
"This message has been generated automatically.\n" +
|
"This message has been generated automatically.\n" +
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
||||||
message = createUserMail(message, authentication);
|
message = createUserMail(message, authentication);
|
||||||
|
|
||||||
this.sendMail(issuer, subject, message);
|
this.sendMail(issuer, subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending validation submission notification email to user: " + issuer, e);
|
logger.error("Error while sending validation submission notification email to user: " + issuer, e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAdminValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
public void sendAdminValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE validator - Test results ";
|
String subject = "OpenAIRE validator - Test results ";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"a validation request has finished. You can retrieve the results by following this url: "+ valBaseUrl+"" + jobId+" .\n\n" +
|
"a validation request has finished. You can retrieve the results by following this url: " + valBaseUrl + "" + jobId + " .\n\n" +
|
||||||
"\n\nUser Contact:"+ issuer +""+
|
"\n\nUser Contact:" + issuer + "" +
|
||||||
"Please do not reply to this message.\n" +
|
"Please do not reply to this message.\n" +
|
||||||
"This message has been generated automatically.\n" +
|
"This message has been generated automatically.\n" +
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
||||||
message = createAdminMail(message);
|
message = createAdminMail(message);
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
this.sendMail(this.provideAdminEmail, subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending validation submission notification email to user: " + issuer, e);
|
logger.error("Error while sending validation submission notification email to user: " + issuer, e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAdminGeneralFailure(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
public void sendAdminGeneralFailure(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE validator - job failure";
|
String subject = "OpenAIRE validator - job failure";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"the validation job that was automatically submitted for the update/registration of the interface "+repositoryInterface.getId()+" ("+repositoryInterface.getBaseurl()+", "+repositoryInterface.getAccessSet()+") of the repository "+repository.getId()+" ("+repository.getOfficialname()+") failed to complete." +
|
"the validation job that was automatically submitted for the update/registration of the interface " + repositoryInterface.getId() + " (" + repositoryInterface.getBaseurl() + ", " + repositoryInterface.getAccessSet() + ") of the repository " + repository.getId() + " (" + repository.getOfficialname() + ") failed to complete." +
|
||||||
"This message has been generated automatically.";
|
"This message has been generated automatically.";
|
||||||
message = createAdminMail(message);
|
message = createAdminMail(message);
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
this.sendMail(this.provideAdminEmail, subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending validation submission notification email to user: " + issuer, e);
|
logger.error("Error while sending validation submission notification email to user: " + issuer, e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAdminUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) throws Exception {
|
public void sendAdminUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE content provider update information for " +
|
String subject = "OpenAIRE content provider update information for " +
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"We received a request to update the basic information for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n\n" +
|
"We received a request to update the basic information for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n\n" +
|
||||||
"Please do not reply to this message\n" +
|
"Please do not reply to this message\n" +
|
||||||
"This message has been generated automatically.";
|
"This message has been generated automatically.";
|
||||||
message = createAdminMail(message);
|
message = createAdminMail(message);
|
||||||
|
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
this.sendMail(this.provideAdminEmail, subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending registration notification email to the administrator", e);
|
logger.error("Error while sending registration notification email to the administrator", e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) throws Exception {
|
public void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE content provider update information for " +
|
String subject = "OpenAIRE content provider update information for " +
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"We received a request to update the basic information for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n\n" +
|
"We received a request to update the basic information for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n\n" +
|
||||||
"Please do not reply to this message\n" +
|
"Please do not reply to this message\n" +
|
||||||
"This message has been generated automatically.\n\n" +
|
"This message has been generated automatically.\n\n" +
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
||||||
message = createUserMail(message, authentication);
|
message = createUserMail(message, authentication);
|
||||||
|
|
||||||
this.sendMail(repository.getRegisteredby(), subject, message);
|
this.sendMail(repository.getRegisteredby(), subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
logger.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
public void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE interface update request started for " +
|
String subject = "OpenAIRE interface update request started for " +
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"We received a request to update the following interface: \n\n" +
|
"We received a request to update the following interface: \n\n" +
|
||||||
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
|
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
|
||||||
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
||||||
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
|
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
|
||||||
"for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
|
"for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
|
||||||
|
|
||||||
if (comment != null)
|
if (comment != null)
|
||||||
message += "\nThe users comment was '" + comment + "'\n";
|
message += "\nThe users comment was '" + comment + "'\n";
|
||||||
|
@ -635,23 +672,22 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
this.sendMail(this.provideAdminEmail, subject, message);
|
this.sendMail(this.provideAdminEmail, subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending registration notification email to the administrator", e);
|
logger.error("Error while sending registration notification email to the administrator", e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
public void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE interface update request started for " +
|
String subject = "OpenAIRE interface update request started for " +
|
||||||
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"We received a request to update the following interface: \n\n" +
|
"We received a request to update the following interface: \n\n" +
|
||||||
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
|
"Base URL: " + repositoryInterface.getBaseurl() + "\n" +
|
||||||
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
"Set: " + repositoryInterface.getAccessSet() + "\n" +
|
||||||
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
|
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" +
|
||||||
"for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
|
"for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
|
||||||
|
|
||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
message += "\n Your comment was '" + comment + "'\n";
|
message += "\n Your comment was '" + comment + "'\n";
|
||||||
|
@ -666,28 +702,26 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
this.sendMail(repository.getRegisteredby(), subject, message);
|
this.sendMail(repository.getRegisteredby(), subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
logger.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception {
|
public void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) {
|
||||||
try {
|
try {
|
||||||
String subject = "OpenAIRE validator - Test submission ";
|
String subject = "OpenAIRE validator - Test submission ";
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
"The validation request you have submitted has started.\n" +
|
"The validation request you have submitted has started.\n" +
|
||||||
"Please do not reply to this message.\n" +
|
"Please do not reply to this message.\n" +
|
||||||
"This message has been generated automatically.\n" +
|
"This message has been generated automatically.\n" +
|
||||||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
||||||
message = createUserMail(message, authentication);
|
message = createUserMail(message, authentication);
|
||||||
|
|
||||||
this.sendMail(jobForValidation.getUserEmail(), subject, message);
|
this.sendMail(jobForValidation.getUserEmail(), subject, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending validation submission notification email to user: " + jobForValidation.getUserEmail(), e);
|
logger.error("Error while sending validation submission notification email to user: " + jobForValidation.getUserEmail(), e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -702,51 +736,50 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
String issuerEmail,
|
String issuerEmail,
|
||||||
String jobId) throws Exception {
|
String jobId) throws Exception {
|
||||||
List<RepositoryInterface> repositoryInterfaces = repositoryService.getRepositoryInterface(repoId);
|
List<RepositoryInterface> repositoryInterfaces = repositoryService.getRepositoryInterface(repoId);
|
||||||
if(repositoryInterfaces.size()==0)
|
if (repositoryInterfaces.isEmpty())
|
||||||
throw new ValidationServiceException("Repository interface with id \""+repoInterfaceId+"\" not found",ValidationServiceException.ErrorCode.GENERAL_ERROR);
|
throw new ValidationServiceException("Repository interface with id \"" + repoInterfaceId + "\" not found", ValidationServiceException.ErrorCode.GENERAL_ERROR);
|
||||||
|
|
||||||
RepositoryInterface repositoryInterface = repositoryInterfaces.stream().filter( repoInterface -> repoInterface.getId().equals(repoInterfaceId)).collect(Collectors.toList()).get(0);
|
RepositoryInterface repositoryInterface = repositoryInterfaces.stream().filter(repoInterface -> repoInterface.getId().equals(repoInterfaceId)).collect(Collectors.toList()).get(0);
|
||||||
Repository repository = repositoryService.getRepositoryById(repoId);
|
Repository repository = repositoryService.getRepositoryById(repoId);
|
||||||
|
|
||||||
if(!isUpdate){
|
if (!isUpdate) {
|
||||||
if(isSuccess){
|
if (isSuccess) {
|
||||||
if(scoreContent>=50 && scoreUsage >= 50){
|
if (scoreContent >= 50 && scoreUsage >= 50) {
|
||||||
this.sendUserRegistrationResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
|
this.sendUserRegistrationResultsSuccessEmail(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication());
|
||||||
this.sendAdminRegistrationResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication());
|
this.sendAdminRegistrationResultsSuccessEmail(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication());
|
||||||
}else{
|
} else {
|
||||||
this.sendUserRegistrationResultsFailureEmail(jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
|
this.sendUserRegistrationResultsFailureEmail(jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication());
|
||||||
this.sendAdminRegistrationResultsFailureEmail(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication());
|
this.sendAdminRegistrationResultsFailureEmail(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication());
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
this.sendAdminGeneralFailure(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication());
|
this.sendAdminGeneralFailure(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication());
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
if(isSuccess){
|
if (isSuccess) {
|
||||||
if(scoreContent>=50 && scoreUsage >= 50){
|
if (scoreContent >= 50 && scoreUsage >= 50) {
|
||||||
this.sendUserUpdateResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
|
this.sendUserUpdateResultsSuccessEmail(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication());
|
||||||
this.sendAdminUpdateResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
|
this.sendAdminUpdateResultsSuccessEmail(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication());
|
||||||
}else{
|
} else {
|
||||||
this.sendUserUpdateResultsFailureEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
|
this.sendUserUpdateResultsFailureEmail(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication());
|
||||||
this.sendAdminUpdateResultsFailureEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
|
this.sendAdminUpdateResultsFailureEmail(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication());
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
this.sendAdminGeneralFailure(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication());
|
this.sendAdminGeneralFailure(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMail(String email, String subject, String message) throws Exception {
|
private void sendMail(String email, String subject, String message) {
|
||||||
this.sendMail(Collections.singletonList(email), subject, message);
|
this.sendMail(Collections.singletonList(email), subject, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMail(List<String> recipients, String subject, String message) throws Exception {
|
public void sendMail(List<String> recipients, String subject, String message) {
|
||||||
try {
|
try {
|
||||||
LOGGER.debug("Sending e-mail\nRecipients: " + recipients + "\nSubject: " + subject + "\nMessage: " + message);
|
logger.debug("Sending e-mail\nRecipients: {}\nSubject: {}\nMessage: {}", recipients, subject, message);
|
||||||
mailLibrary.sendEmail(recipients.toArray(new String[]{}), subject, message);
|
mailLibrary.sendEmail(recipients.toArray(new String[]{}), subject, message);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error sending e-mail\nRecipients: " + recipients + "\nSubject: " + subject + "\nMessage: " + message, e);
|
logger.error("Error sending e-mail\nRecipients: " + recipients + "\nSubject: " + subject + "\nMessage: " + message, e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,13 +795,20 @@ public class EmailUtilsImpl implements EmailUtils {
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String createRepoAdminsMail(String body) {
|
||||||
|
body = "Dear repository admins,\n\n" + body;
|
||||||
|
body += "\n\nBest Regards,\nthe OpenAIRE technical team\n";
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
private String getUserName(Authentication authentication) {
|
private String getUserName(Authentication authentication) {
|
||||||
String user = "user";
|
String user = "user";
|
||||||
if (authentication != null) {
|
if (authentication != null) {
|
||||||
try {
|
try {
|
||||||
user = ((OIDCAuthenticationToken) authentication).getUserInfo().getName();
|
user = ((OIDCAuthenticationToken) authentication).getUserInfo().getName();
|
||||||
} catch (NullPointerException ex) {}
|
} catch (NullPointerException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return user;
|
return user; // It may be just "user". TODO - Wouldn't be better if it was null?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
|
import eu.dnetlib.repo.manager.domain.*;
|
||||||
|
import eu.dnetlib.repo.manager.domain.dto.User;
|
||||||
|
import eu.dnetlib.repo.manager.exception.ResourceConflictException;
|
||||||
|
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||||
|
import eu.dnetlib.repo.manager.repository.InterfaceComplianceRequestsRepository;
|
||||||
|
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class InterfaceComplianceService {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(InterfaceComplianceService.class);
|
||||||
|
|
||||||
|
|
||||||
|
private final InterfaceComplianceRequestsRepository repository;
|
||||||
|
private final EmailUtils emailUtils;
|
||||||
|
private final AuthorizationService authorizationService;
|
||||||
|
private final RepositoryService repositoryService;
|
||||||
|
|
||||||
|
public InterfaceComplianceService(InterfaceComplianceRequestsRepository repository,
|
||||||
|
EmailUtils emailUtils,
|
||||||
|
AuthorizationService authorizationService,
|
||||||
|
RepositoryService repositoryService) {
|
||||||
|
this.repository = repository;
|
||||||
|
this.emailUtils = emailUtils;
|
||||||
|
this.authorizationService = authorizationService;
|
||||||
|
this.repositoryService = repositoryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0 0 * * *") // every day at 00:00
|
||||||
|
public void cleanUp() {
|
||||||
|
Set<InterfaceComplianceRequest> requests = getOutdated();
|
||||||
|
for (InterfaceComplianceRequest request : requests) {
|
||||||
|
try {
|
||||||
|
Map<String, RepositoryInterface> repositoryInterfaceMap = repositoryService.getRepositoryInterface(request.getRepositoryId())
|
||||||
|
.stream()
|
||||||
|
.collect(Collectors.toMap(ApiDetails::getId, i -> i));
|
||||||
|
Repository repo = repositoryService.getRepositoryById(request.getRepositoryId());
|
||||||
|
RepositoryInterface iFace = repositoryInterfaceMap.get(request.getInterfaceId());
|
||||||
|
List<User> repositoryAdmins = authorizationService.getAdminsOfRepo(request.getRepositoryId());
|
||||||
|
emailUtils.sendUserUpdateInterfaceComplianceFailure(repositoryAdmins.stream().map(User::getEmail).collect(Collectors.toList()), repo, iFace, request);
|
||||||
|
emailUtils.sendAdminUpdateInterfaceComplianceFailure(repo, iFace, request);
|
||||||
|
} catch (JSONException | ResourceNotFoundException e) {
|
||||||
|
logger.error("Error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
repository.deleteAll(requests);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<InterfaceComplianceRequest> getOutdated() {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.add(Calendar.DATE, -7);
|
||||||
|
return this.repository.findAllBySubmissionDateBefore(calendar.getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<InterfaceComplianceRequest> getById(InterfaceComplianceRequestId id) {
|
||||||
|
return this.repository.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterable<InterfaceComplianceRequest> get() {
|
||||||
|
return this.repository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public InterfaceComplianceRequest create(InterfaceComplianceRequest request) {
|
||||||
|
Optional<InterfaceComplianceRequest> existing = getById(request.getId());
|
||||||
|
if (existing.isPresent()) {
|
||||||
|
logger.warn("New Request: {}\nExisting request: {}", request, existing.get());
|
||||||
|
throw new ResourceConflictException("A request for altering compliance already exists. Desired Compatibility value: " + existing.get().getDesiredCompatibilityLevel());
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.repository.save(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(InterfaceComplianceRequestId id) {
|
||||||
|
this.repository.deleteById(id);
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,10 +7,11 @@ import eu.dnetlib.repo.manager.domain.Constants;
|
||||||
import eu.dnetlib.repo.manager.domain.JobsOfUser;
|
import eu.dnetlib.repo.manager.domain.JobsOfUser;
|
||||||
import eu.dnetlib.repo.manager.utils.CrisValidatorUtils;
|
import eu.dnetlib.repo.manager.utils.CrisValidatorUtils;
|
||||||
import gr.uoa.di.driver.util.ServiceLocator;
|
import gr.uoa.di.driver.util.ServiceLocator;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.eurocris.openaire.cris.validator.model.Job;
|
import org.eurocris.openaire.cris.validator.model.Job;
|
||||||
import org.eurocris.openaire.cris.validator.service.MapJobDao;
|
import org.eurocris.openaire.cris.validator.service.MapJobDao;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -22,6 +23,8 @@ import java.util.stream.Collectors;
|
||||||
@Service("monitorService")
|
@Service("monitorService")
|
||||||
public class MonitorServiceImpl implements MonitorService {
|
public class MonitorServiceImpl implements MonitorService {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(MonitorServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MapJobDao crisJobs;
|
private MapJobDao crisJobs;
|
||||||
|
|
||||||
|
@ -41,9 +44,6 @@ public class MonitorServiceImpl implements MonitorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger
|
|
||||||
.getLogger(MonitorServiceImpl.class);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JobsOfUser getJobsOfUser(String user,
|
public JobsOfUser getJobsOfUser(String user,
|
||||||
String jobType,
|
String jobType,
|
||||||
|
@ -54,9 +54,6 @@ public class MonitorServiceImpl implements MonitorService {
|
||||||
String validationStatus,
|
String validationStatus,
|
||||||
String includeJobsTotal) throws JSONException, ValidatorServiceException {
|
String includeJobsTotal) throws JSONException, ValidatorServiceException {
|
||||||
|
|
||||||
LOGGER.debug("Getting jobs of user : " + user);
|
|
||||||
LOGGER.debug(user + "/" + jobType + "/" + offset + "/" + dateFrom + "/" + dateTo + "/" + validationStatus + "/" + includeJobsTotal);
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
|
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -154,7 +151,7 @@ public class MonitorServiceImpl implements MonitorService {
|
||||||
public int getJobsOfUserPerValidationStatus(String user,
|
public int getJobsOfUserPerValidationStatus(String user,
|
||||||
String jobType,
|
String jobType,
|
||||||
String validationStatus) throws JSONException {
|
String validationStatus) throws JSONException {
|
||||||
LOGGER.debug("Getting job with validation status : " + validationStatus);
|
logger.debug("Getting job with validation status : " + validationStatus);
|
||||||
|
|
||||||
if (jobType.equalsIgnoreCase("cris")) {
|
if (jobType.equalsIgnoreCase("cris")) {
|
||||||
return crisJobs.getJobs(user, validationStatus).size();
|
return crisJobs.getJobs(user, validationStatus).size();
|
||||||
|
@ -163,7 +160,7 @@ public class MonitorServiceImpl implements MonitorService {
|
||||||
try {
|
try {
|
||||||
return getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus);
|
return getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus);
|
||||||
} catch (ValidatorServiceException e) {
|
} catch (ValidatorServiceException e) {
|
||||||
LOGGER.error(e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -171,12 +168,12 @@ public class MonitorServiceImpl implements MonitorService {
|
||||||
@Override
|
@Override
|
||||||
public StoredJob getJobSummary(String jobId,
|
public StoredJob getJobSummary(String jobId,
|
||||||
String groupBy) throws JSONException {
|
String groupBy) throws JSONException {
|
||||||
LOGGER.debug("Getting job summary with id : " + jobId);
|
logger.debug("Getting job summary with id : " + jobId);
|
||||||
StoredJob job = null;
|
StoredJob job = null;
|
||||||
try {
|
try {
|
||||||
job = getValidationService().getStoredJob(Integer.parseInt(jobId), groupBy);
|
job = getValidationService().getStoredJob(Integer.parseInt(jobId), groupBy);
|
||||||
} catch (ValidatorServiceException e) {
|
} catch (ValidatorServiceException e) {
|
||||||
LOGGER.error(e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
|
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
|
||||||
|
|
|
@ -2,12 +2,13 @@ package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.dnetlib.domain.data.PiwikInfo;
|
import eu.dnetlib.domain.data.PiwikInfo;
|
||||||
import eu.dnetlib.repo.manager.domain.Repository;
|
|
||||||
import eu.dnetlib.repo.manager.domain.OrderByField;
|
import eu.dnetlib.repo.manager.domain.OrderByField;
|
||||||
import eu.dnetlib.repo.manager.domain.OrderByType;
|
import eu.dnetlib.repo.manager.domain.OrderByType;
|
||||||
|
import eu.dnetlib.repo.manager.domain.Repository;
|
||||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
@ -32,6 +33,9 @@ import java.util.Map;
|
||||||
@Service("piwikService")
|
@Service("piwikService")
|
||||||
public class PiWikServiceImpl implements PiWikService {
|
public class PiWikServiceImpl implements PiWikService {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(PiWikServiceImpl.class);
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
|
||||||
|
@ -47,20 +51,20 @@ public class PiWikServiceImpl implements PiWikService {
|
||||||
@Qualifier("emailUtils")
|
@Qualifier("emailUtils")
|
||||||
private EmailUtils emailUtils;
|
private EmailUtils emailUtils;
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger
|
|
||||||
.getLogger(PiWikServiceImpl.class);
|
|
||||||
|
|
||||||
private final static String GET_PIWIK_SITE = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site where repositoryid = ?;";
|
private static final String GET_PIWIK_SITE = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site where repositoryid = ? LIMIT 1;";
|
||||||
|
|
||||||
private final static String INSERT_PIWIK_INFO = "insert into piwik_site (repositoryid, siteid, creationdate, requestorname, requestoremail, validated, repositoryname, country, authenticationtoken) values (?, ?, now(), ?, ?, ?, ?, ?, ?)";
|
private static final String INSERT_PIWIK_INFO = "insert into piwik_site (repositoryid, siteid, creationdate, requestorname, requestoremail, validated, repositoryname, country, authenticationtoken) values (?, ?, now(), ?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
private final static String GET_PIWIK_SITES = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site ";
|
private static final String UPDATE_PIWIK_INFO = "update piwik_site set siteid = ?, creationdate = now(), requestorname = ?, requestoremail = ?, validated = ?, repositoryname = ?, country = ?, authenticationtoken = ? where repositoryid = ?";
|
||||||
|
|
||||||
private final static String GET_PIWIK_SITES_TOTAL = "select count(*) as totals from piwik_site ";
|
private static final String GET_PIWIK_SITES = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site ";
|
||||||
|
|
||||||
private final static String APPROVE_PIWIK_SITE = "update piwik_site set validated=true, validationdate=now() where repositoryid = ?;";
|
private static final String GET_PIWIK_SITES_TOTAL = "select count(*) as totals from piwik_site ";
|
||||||
|
|
||||||
private RowMapper<PiwikInfo> piwikRowMapper = (rs, i) -> new PiwikInfo(rs.getString("repositoryid"), getOpenaireId(rs.getString("repositoryid")), rs.getString("repositoryname"), rs.getString("country"),
|
private static final String APPROVE_PIWIK_SITE = "update piwik_site set validated=true, validationdate=now() where repositoryid = ?;";
|
||||||
|
|
||||||
|
private final RowMapper<PiwikInfo> piwikRowMapper = (rs, i) -> new PiwikInfo(rs.getString("repositoryid"), getOpenaireId(rs.getString("repositoryid")), rs.getString("repositoryname"), rs.getString("country"),
|
||||||
rs.getString("siteid"), rs.getString("authenticationtoken"), rs.getTimestamp("creationdate"), rs.getString("requestorname"), rs.getString("requestoremail"),
|
rs.getString("siteid"), rs.getString("authenticationtoken"), rs.getTimestamp("creationdate"), rs.getString("requestorname"), rs.getString("requestoremail"),
|
||||||
rs.getBoolean("validated"), rs.getTimestamp("validationdate"), rs.getString("comment"));
|
rs.getBoolean("validated"), rs.getTimestamp("validationdate"), rs.getString("comment"));
|
||||||
|
|
||||||
|
@ -78,9 +82,15 @@ public class PiWikServiceImpl implements PiWikService {
|
||||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or (hasAuthority('REGISTERED_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)")
|
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or (hasAuthority('REGISTERED_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)")
|
||||||
public PiwikInfo savePiwikInfo(PiwikInfo piwikInfo) {
|
public PiwikInfo savePiwikInfo(PiwikInfo piwikInfo) {
|
||||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||||
jdbcTemplate.update(INSERT_PIWIK_INFO, new Object[]{piwikInfo.getRepositoryId(), piwikInfo.getSiteId(), piwikInfo.getRequestorName(),
|
if (getPiwikSiteForRepo(piwikInfo.getRepositoryId()) == null) {
|
||||||
piwikInfo.getRequestorEmail(), piwikInfo.isValidated(), piwikInfo.getRepositoryName(), piwikInfo.getCountry(), piwikInfo.getAuthenticationToken()},
|
jdbcTemplate.update(INSERT_PIWIK_INFO, new Object[]{piwikInfo.getRepositoryId(), piwikInfo.getSiteId(), piwikInfo.getRequestorName(),
|
||||||
new int[]{Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR});
|
piwikInfo.getRequestorEmail(), piwikInfo.isValidated(), piwikInfo.getRepositoryName(), piwikInfo.getCountry(), piwikInfo.getAuthenticationToken()},
|
||||||
|
new int[]{Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR});
|
||||||
|
} else {
|
||||||
|
jdbcTemplate.update(UPDATE_PIWIK_INFO, new Object[]{piwikInfo.getSiteId(), piwikInfo.getRequestorName(), piwikInfo.getRequestorEmail(),
|
||||||
|
piwikInfo.isValidated(), piwikInfo.getRepositoryName(), piwikInfo.getCountry(), piwikInfo.getAuthenticationToken(), piwikInfo.getRepositoryId()},
|
||||||
|
new int[]{Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR});
|
||||||
|
}
|
||||||
return piwikInfo;
|
return piwikInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,10 +178,10 @@ public class PiWikServiceImpl implements PiWikService {
|
||||||
emailUtils.sendUserMetricsEnabled(piwikInfo);
|
emailUtils.sendUserMetricsEnabled(piwikInfo);
|
||||||
|
|
||||||
} catch (EmptyResultDataAccessException e) {
|
} catch (EmptyResultDataAccessException e) {
|
||||||
LOGGER.error("Error while approving piwik site: ", e);
|
logger.error("Error while approving piwik site: ", e);
|
||||||
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending email to administrator or user about the enabling of metrics", e);
|
logger.error("Error while sending email to administrator or user about the enabling of metrics", e);
|
||||||
throw new RepositoryServiceException(e, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
throw new RepositoryServiceException(e, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>("OK", HttpStatus.OK);
|
return new ResponseEntity<>("OK", HttpStatus.OK);
|
||||||
|
@ -183,9 +193,9 @@ public class PiWikServiceImpl implements PiWikService {
|
||||||
String repoWebsite,
|
String repoWebsite,
|
||||||
PiwikInfo piwikInfo) throws RepositoryServiceException {
|
PiwikInfo piwikInfo) throws RepositoryServiceException {
|
||||||
try {
|
try {
|
||||||
String URL = analyticsURL + "siteName=" + URLEncoder.encode(officialName, "UTF-8") + "&url="
|
String url = analyticsURL + "siteName=" + URLEncoder.encode(officialName, "UTF-8") + "&url="
|
||||||
+ URLEncoder.encode(repoWebsite, "UTF-8");
|
+ URLEncoder.encode(repoWebsite, "UTF-8");
|
||||||
Map map = new ObjectMapper().readValue(new URL(URL), Map.class);
|
Map map = new ObjectMapper().readValue(new URL(url), Map.class);
|
||||||
String siteId = null;
|
String siteId = null;
|
||||||
if (map.get("value") != null) {
|
if (map.get("value") != null) {
|
||||||
siteId = map.get("value").toString();
|
siteId = map.get("value").toString();
|
||||||
|
@ -202,13 +212,13 @@ public class PiWikServiceImpl implements PiWikService {
|
||||||
emailUtils.sendAdministratorRequestToEnableMetrics(piwikInfo);
|
emailUtils.sendAdministratorRequestToEnableMetrics(piwikInfo);
|
||||||
emailUtils.sendUserRequestToEnableMetrics(piwikInfo);
|
emailUtils.sendUserRequestToEnableMetrics(piwikInfo);
|
||||||
} catch (UnsupportedEncodingException uee) {
|
} catch (UnsupportedEncodingException uee) {
|
||||||
LOGGER.error("Error while creating piwikScript URL", uee);
|
logger.error("Error while creating piwikScript URL", uee);
|
||||||
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
LOGGER.error("Error while creating piwik site", ioe);
|
logger.error("Error while creating piwik site", ioe);
|
||||||
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while sending email to administrator or user about the request to enable metrics", e);
|
logger.error("Error while sending email to administrator or user about the request to enable metrics", e);
|
||||||
throw new RepositoryServiceException(e, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
throw new RepositoryServiceException(e, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||||
}
|
}
|
||||||
return piwikInfo;
|
return piwikInfo;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package eu.dnetlib.repo.manager.service;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.domain.Repository;
|
|
||||||
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
|
|
||||||
import eu.dnetlib.repo.manager.domain.*;
|
import eu.dnetlib.repo.manager.domain.*;
|
||||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||||
|
@ -44,12 +42,6 @@ public interface RepositoryService {
|
||||||
|
|
||||||
Repository getRepositoryById(String id) throws JSONException, ResourceNotFoundException;
|
Repository getRepositoryById(String id) throws JSONException, ResourceNotFoundException;
|
||||||
|
|
||||||
List<AggregationDetails> getRepositoryAggregations(String id) throws JSONException;
|
|
||||||
|
|
||||||
List<AggregationDetails> getRepositoryAggregations(String id, int from, int size) throws JSONException;
|
|
||||||
|
|
||||||
Map<String, List<AggregationDetails>> getRepositoryAggregationsByYear(String id) throws JSONException;
|
|
||||||
|
|
||||||
List<Repository> getRepositoriesByName(String name,
|
List<Repository> getRepositoriesByName(String name,
|
||||||
String page,
|
String page,
|
||||||
String size) throws JSONException;
|
String size) throws JSONException;
|
||||||
|
@ -68,7 +60,9 @@ public interface RepositoryService {
|
||||||
|
|
||||||
RepositoryInterface addRepositoryInterface(String datatype,
|
RepositoryInterface addRepositoryInterface(String datatype,
|
||||||
String repoId,
|
String repoId,
|
||||||
String comment, RepositoryInterface repositoryInterface) throws Exception;
|
String comment,
|
||||||
|
RepositoryInterface repositoryInterface,
|
||||||
|
String desiredCompatibilityLevel) throws Exception;
|
||||||
|
|
||||||
List<String> getDnetCountries();
|
List<String> getDnetCountries();
|
||||||
|
|
||||||
|
@ -92,6 +86,7 @@ public interface RepositoryService {
|
||||||
|
|
||||||
Map<String, String> getListLatestUpdate(String mode) throws JSONException;
|
Map<String, String> getListLatestUpdate(String mode) throws JSONException;
|
||||||
|
|
||||||
RepositoryInterface updateRepositoryInterface(String repoId, String comment, RepositoryInterface repositoryInterface) throws Exception;
|
RepositoryInterface updateRepositoryInterface(String repoId, String comment, RepositoryInterface repositoryInterface, String desiredCompatibilityLevel) throws Exception;
|
||||||
|
|
||||||
|
void updateInterfaceCompliance(String repositoryId, String repositoryInterfaceId, String compliance);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||||
import eu.dnetlib.repo.manager.domain.Repository;
|
|
||||||
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
|
|
||||||
import eu.dnetlib.domain.enabling.Vocabulary;
|
import eu.dnetlib.domain.enabling.Vocabulary;
|
||||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||||
import eu.dnetlib.repo.manager.domain.*;
|
import eu.dnetlib.repo.manager.domain.*;
|
||||||
|
@ -20,13 +18,15 @@ import eu.dnetlib.repo.manager.service.security.AuthoritiesUpdater;
|
||||||
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
||||||
import eu.dnetlib.repo.manager.service.security.RoleMappingService;
|
import eu.dnetlib.repo.manager.service.security.RoleMappingService;
|
||||||
import eu.dnetlib.repo.manager.utils.Converter;
|
import eu.dnetlib.repo.manager.utils.Converter;
|
||||||
|
import eu.dnetlib.repo.manager.utils.DateUtils;
|
||||||
import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader;
|
import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
@ -46,22 +46,23 @@ import java.io.IOException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service("repositoryService")
|
@Service("repositoryService")
|
||||||
public class RepositoryServiceImpl implements RepositoryService {
|
public class RepositoryServiceImpl implements RepositoryService {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(RepositoryServiceImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(RepositoryServiceImpl.class);
|
||||||
|
|
||||||
private final AuthorizationService authorizationService;
|
private final AuthorizationService authorizationService;
|
||||||
private final RoleMappingService roleMappingService;
|
private final RoleMappingService roleMappingService;
|
||||||
private final AaiRegistryService registryCalls;
|
private final AaiRegistryService registryCalls;
|
||||||
private final AuthoritiesUpdater authoritiesUpdater;
|
private final AuthoritiesUpdater authoritiesUpdater;
|
||||||
private final RestTemplate restTemplate;
|
private final RestTemplate restTemplate;
|
||||||
|
private final ObjectMapper objectMapper;
|
||||||
private final VocabularyLoader vocabularyLoader;
|
private final VocabularyLoader vocabularyLoader;
|
||||||
private final PiWikService piWikService;
|
private final PiWikService piWikService;
|
||||||
private final EmailUtils emailUtils;
|
private final EmailUtils emailUtils;
|
||||||
private final ValidatorService validatorService;
|
private final ValidatorService validatorService;
|
||||||
|
private final InterfaceComplianceService interfaceComplianceService;
|
||||||
|
|
||||||
@Value("${services.provide.clients.dsm}")
|
@Value("${services.provide.clients.dsm}")
|
||||||
private String baseAddress;
|
private String baseAddress;
|
||||||
|
@ -94,10 +95,12 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
AuthoritiesUpdater authoritiesUpdater,
|
AuthoritiesUpdater authoritiesUpdater,
|
||||||
VocabularyLoader vocabularyLoader,
|
VocabularyLoader vocabularyLoader,
|
||||||
RestTemplate restTemplate,
|
RestTemplate restTemplate,
|
||||||
|
ObjectMapper objectMapper,
|
||||||
Converter converter,
|
Converter converter,
|
||||||
@Lazy EmailUtils emailUtils,
|
@Lazy EmailUtils emailUtils,
|
||||||
@Lazy ValidatorService validatorService,
|
@Lazy ValidatorService validatorService,
|
||||||
@Lazy PiWikService piWikService) {
|
@Lazy PiWikService piWikService,
|
||||||
|
@Lazy InterfaceComplianceService interfaceComplianceService) {
|
||||||
this.authorizationService = authorizationService;
|
this.authorizationService = authorizationService;
|
||||||
this.roleMappingService = roleMappingService;
|
this.roleMappingService = roleMappingService;
|
||||||
this.registryCalls = registryCalls;
|
this.registryCalls = registryCalls;
|
||||||
|
@ -108,12 +111,13 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
this.emailUtils = emailUtils;
|
this.emailUtils = emailUtils;
|
||||||
this.validatorService = validatorService;
|
this.validatorService = validatorService;
|
||||||
this.restTemplate = restTemplate;
|
this.restTemplate = restTemplate;
|
||||||
|
this.objectMapper = objectMapper;
|
||||||
|
this.interfaceComplianceService = interfaceComplianceService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void init() {
|
private void init() {
|
||||||
LOGGER.debug("Initialization method of repository api!");
|
logger.debug("Initialization method of repository api! Updated version!");
|
||||||
LOGGER.debug("Updated version!");
|
|
||||||
|
|
||||||
for (String key : this.getVocabulary("dnet:datasource_typologies").getAsMap().keySet()) {
|
for (String key : this.getVocabulary("dnet:datasource_typologies").getAsMap().keySet()) {
|
||||||
if (key.contains("aggregator")) {
|
if (key.contains("aggregator")) {
|
||||||
|
@ -137,7 +141,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
}
|
}
|
||||||
|
|
||||||
httpHeaders = new HttpHeaders();
|
httpHeaders = new HttpHeaders();
|
||||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
httpHeaders.setContentType(MediaType.valueOf(MediaType.APPLICATION_JSON_VALUE));
|
||||||
|
|
||||||
for (String vocName : vocabularyNames) {
|
for (String vocName : vocabularyNames) {
|
||||||
vocabularyMap.put(vocName, vocabularyLoader.getVocabulary(vocName, Locale.ENGLISH, Locale.ROOT));
|
vocabularyMap.put(vocName, vocabularyLoader.getVocabulary(vocName, Locale.ENGLISH, Locale.ROOT));
|
||||||
|
@ -148,8 +152,6 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
countriesMap.put(c.getName(), c.getCode());
|
countriesMap.put(c.getName(), c.getCode());
|
||||||
inverseCountriesMap.put(c.getCode(), c.getName());
|
inverseCountriesMap.put(c.getCode(), c.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -174,17 +176,19 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
@Override
|
@Override
|
||||||
public List<Repository> getRepositories(List<String> ids, int page, int size) throws JSONException {
|
public List<Repository> getRepositories(List<String> ids, int page, int size) throws JSONException {
|
||||||
List<Repository> repos = new ArrayList<>();
|
List<Repository> repos = new ArrayList<>();
|
||||||
LOGGER.debug("Retrieving repositories with ids : " + String.join(", ", ids));
|
logger.debug("Retrieving repositories with ids : {}", String.join(", ", ids));
|
||||||
UriComponents uriComponents = searchDatasource(Integer.toString(Math.abs(page)), Integer.toString(Math.abs(size)));
|
UriComponents uriComponents = searchDatasource(Integer.toString(Math.abs(page)), Integer.toString(Math.abs(size)));
|
||||||
RequestFilter requestFilter = new RequestFilter();
|
RequestFilter requestFilter = new RequestFilter();
|
||||||
|
|
||||||
for (String repoId : ids) {
|
for (String repoId : ids) {
|
||||||
requestFilter.setId(repoId);
|
requestFilter.setId(repoId);
|
||||||
List<Repository> rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, List.class);
|
List rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, List.class);
|
||||||
|
|
||||||
// repos.addAll(converter.toRepositoryList(new JSONObject(rs)));
|
// repos.addAll(converter.toRepositoryList(new JSONObject(rs)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO - "repos" is EMPTY!!
|
||||||
|
|
||||||
for (Repository r : repos)
|
for (Repository r : repos)
|
||||||
r.setPiwikInfo(piWikService.getPiwikSiteForRepo(r.getId()));
|
r.setPiwikInfo(piWikService.getPiwikSiteForRepo(r.getId()));
|
||||||
return repos;
|
return repos;
|
||||||
|
@ -204,27 +208,30 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
@Override
|
@Override
|
||||||
public List<RepositorySnippet> getRepositoriesSnippets(List<String> ids, int page, int size) throws Exception {
|
public List<RepositorySnippet> getRepositoriesSnippets(List<String> ids, int page, int size) throws Exception {
|
||||||
List<RepositorySnippet> resultSet = new ArrayList<>();
|
List<RepositorySnippet> resultSet = new ArrayList<>();
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
|
|
||||||
// here page should be 0
|
// here page should be 0
|
||||||
UriComponents uriComponents = searchSnipperDatasource(Integer.toString(Math.abs(page)), Integer.toString(Math.abs(size)));
|
UriComponents uriComponents = searchSnippetDatasource(Integer.toString(Math.abs(page)), Integer.toString(Math.abs(size)));
|
||||||
RequestFilter requestFilter = new RequestFilter();
|
RequestFilter requestFilter = new RequestFilter();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (String repoId : ids) {
|
for (String repoId : ids) {
|
||||||
requestFilter.setId(repoId);
|
requestFilter.setId(repoId);
|
||||||
|
|
||||||
String rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String.class);
|
DatasourceResponse rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, DatasourceResponse.class);
|
||||||
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
if (rs == null) {
|
||||||
resultSet.addAll(mapper.readValue(String.valueOf(jsonArray),
|
logger.error("The \"DatasourceResponse\" is null!");
|
||||||
mapper.getTypeFactory().constructCollectionType(List.class, RepositorySnippet.class)));
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
resultSet.addAll(objectMapper.readValue(objectMapper.writeValueAsString(rs.getDatasourceInfo()),
|
||||||
|
objectMapper.getTypeFactory().constructCollectionType(List.class, RepositorySnippet.class)));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.debug("Exception on getRepositoriesSnippetOfUser", e);
|
logger.debug("Exception on getRepositoriesSnippetOfUser", e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.debug("resultSet:" + resultSet);
|
logger.debug("resultSet: {}", resultSet);
|
||||||
resultSet.parallelStream().forEach(repositorySnippet -> {
|
resultSet.parallelStream().forEach(repositorySnippet -> {
|
||||||
repositorySnippet.setPiwikInfo(piWikService.getPiwikSiteForRepo(repositorySnippet.getId()));
|
repositorySnippet.setPiwikInfo(piWikService.getPiwikSiteForRepo(repositorySnippet.getId()));
|
||||||
});
|
});
|
||||||
|
@ -237,7 +244,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
String mode,
|
String mode,
|
||||||
Boolean managed) throws JSONException, IOException {
|
Boolean managed) throws JSONException, IOException {
|
||||||
|
|
||||||
LOGGER.debug("Getting repositories by country!");
|
logger.debug("Getting repositories by country!");
|
||||||
int page = 0;
|
int page = 0;
|
||||||
int size = 100;
|
int size = 100;
|
||||||
List<RepositorySnippet> resultSet = new ArrayList<>();
|
List<RepositorySnippet> resultSet = new ArrayList<>();
|
||||||
|
@ -250,24 +257,17 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
filterKey = "CRIS system";
|
filterKey = "CRIS system";
|
||||||
|
|
||||||
|
|
||||||
LOGGER.debug("Country code equals : " + country);
|
logger.debug("Country code equals : {} | Filter mode equals : {}", country, filterKey);
|
||||||
LOGGER.debug("Filter mode equals : " + filterKey);
|
|
||||||
|
|
||||||
UriComponents uriComponents = searchSnipperDatasource(String.valueOf(page), String.valueOf(size));
|
UriComponents uriComponents = searchSnippetDatasource(String.valueOf(page), String.valueOf(size));
|
||||||
RequestFilter requestFilter = new RequestFilter();
|
RequestFilter requestFilter = new RequestFilter();
|
||||||
requestFilter.setCountry(country);
|
requestFilter.setCountry(country);
|
||||||
requestFilter.setEoscDatasourceType(filterKey);
|
requestFilter.setEoscDatasourceType(filterKey);
|
||||||
|
|
||||||
String rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String.class);
|
Map rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, Map.class);
|
||||||
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
if (rs != null) {
|
||||||
while (jsonArray.length() > 0) {
|
resultSet.addAll(mapper.readValue(mapper.writeValueAsString(rs.get("datasourceInfo")),
|
||||||
|
|
||||||
resultSet.addAll(mapper.readValue(String.valueOf(jsonArray),
|
|
||||||
mapper.getTypeFactory().constructCollectionType(List.class, RepositorySnippet.class)));
|
mapper.getTypeFactory().constructCollectionType(List.class, RepositorySnippet.class)));
|
||||||
page += 1;
|
|
||||||
uriComponents = searchSnipperDatasource(String.valueOf(page), String.valueOf(size));
|
|
||||||
rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String.class);
|
|
||||||
jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
|
||||||
}
|
}
|
||||||
return resultSet;
|
return resultSet;
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
public List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName,
|
public List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName,
|
||||||
String officialName, String requestSortBy, String order, int page, int pageSize) throws Exception {
|
String officialName, String requestSortBy, String order, int page, int pageSize) throws Exception {
|
||||||
|
|
||||||
LOGGER.debug("Searching registered repositories");
|
logger.debug("Searching registered repositories");
|
||||||
|
|
||||||
Paging<RepositorySnippet> snippets = null;
|
Paging<RepositorySnippet> snippets = null;
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
@ -289,28 +289,26 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
requestFilter.setEnglishname(englishName);
|
requestFilter.setEnglishname(englishName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String.class);
|
Map rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, Map.class);
|
||||||
if (rs == null) {
|
if (rs == null) {
|
||||||
LOGGER.error(String.format("DSM response is null : [url=%s]", uriComponents.toUri()));
|
logger.error("DSM response is null : [url={}]", uriComponents.toUri());
|
||||||
} else {
|
} else {
|
||||||
JSONObject response = new JSONObject(rs);
|
Header header = mapper.readValue(mapper.writeValueAsString(rs.get("header")), Header.class);
|
||||||
JSONArray jsonArray = (JSONArray) response.get("datasourceInfo");
|
|
||||||
Header header = mapper.readValue(response.get("header").toString(), Header.class);
|
|
||||||
snippets = Paging.of(header,
|
snippets = Paging.of(header,
|
||||||
mapper.readValue(
|
mapper.readValue(
|
||||||
String.valueOf(jsonArray),
|
mapper.writeValueAsString(rs.get("datasourceInfo")),
|
||||||
mapper.getTypeFactory().constructCollectionType(List.class, RepositorySnippet.class)));
|
mapper.getTypeFactory().constructCollectionType(List.class, RepositorySnippet.class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error searching registered datasources", e);
|
logger.error("Error searching registered datasources", e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
return snippets != null ? snippets.getResults() : null; // TODO: return paging when ui is compatible
|
return snippets != null ? snippets.getResults() : null; // TODO: return paging when ui is compatible
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTotalRegisteredRepositories() {
|
public int getTotalRegisteredRepositories() throws NullPointerException {
|
||||||
UriComponents uriComponents = UriComponentsBuilder
|
UriComponents uriComponents = UriComponentsBuilder
|
||||||
.fromHttpUrl(baseAddress + "/ds/countregistered")
|
.fromHttpUrl(baseAddress + "/ds/countregistered")
|
||||||
.queryParam("fromDate", "1900-01-01")
|
.queryParam("fromDate", "1900-01-01")
|
||||||
|
@ -327,16 +325,16 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Repository> getRepositoriesOfUser(String page, String size) throws JSONException {
|
public List<Repository> getRepositoriesOfUser(String page, String size) throws JSONException {
|
||||||
String userEmail = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail();
|
logger.debug("Retrieving repositories of authenticated user : {}",
|
||||||
LOGGER.debug("Retrieving repositories of authenticated user : " + userEmail);
|
((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail());
|
||||||
Collection<String> repoIds = roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRoles());
|
Collection<String> repoIds = roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRoles());
|
||||||
return getRepositories(new ArrayList<>(repoIds));
|
return getRepositories(new ArrayList<>(repoIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Repository> getRepositoriesOfUser(String userEmail, String page, String size) throws JSONException {
|
public List<Repository> getRepositoriesOfUser(String userEmail, String page, String size) throws JSONException {
|
||||||
LOGGER.debug("Retrieving repositories of authenticated user : " + userEmail);
|
logger.debug("Retrieving repositories of authenticated user : {}", userEmail);
|
||||||
Collection<String> repoIds = roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRoles(userEmail));
|
Collection<String> repoIds = roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRolesByEmail(userEmail));
|
||||||
return getRepositories(new ArrayList<>(repoIds));
|
return getRepositories(new ArrayList<>(repoIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,7 +349,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
int to = from + Integer.parseInt(size);
|
int to = from + Integer.parseInt(size);
|
||||||
List<String> repoIds = new ArrayList<>();
|
List<String> repoIds = new ArrayList<>();
|
||||||
if (userEmail != null && !"".equals(userEmail)) {
|
if (userEmail != null && !"".equals(userEmail)) {
|
||||||
repoIds.addAll(roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRoles(userEmail)));
|
repoIds.addAll(roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRolesByEmail(userEmail)));
|
||||||
} else {
|
} else {
|
||||||
repoIds.addAll(roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRoles()));
|
repoIds.addAll(roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRoles()));
|
||||||
}
|
}
|
||||||
|
@ -367,13 +365,18 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
@Override
|
@Override
|
||||||
public RepositorySnippet getRepositorySnippetById(String id) throws JSONException, ResourceNotFoundException {
|
public RepositorySnippet getRepositorySnippetById(String id) throws JSONException, ResourceNotFoundException {
|
||||||
|
|
||||||
LOGGER.debug("Retrieving repositories with id : " + id);
|
logger.debug("Retrieving repositories with id : {}", id);
|
||||||
RepositorySnippet repo;
|
RepositorySnippet repo;
|
||||||
UriComponents uriComponents = searchSnipperDatasource("0", "100");
|
UriComponents uriComponents = searchSnippetDatasource("0", "100");
|
||||||
RequestFilter requestFilter = new RequestFilter();
|
RequestFilter requestFilter = new RequestFilter();
|
||||||
requestFilter.setId(id);
|
requestFilter.setId(id);
|
||||||
|
|
||||||
String rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String.class);
|
String rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String.class);
|
||||||
|
if (rs == null) {
|
||||||
|
logger.error("The result is null!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
||||||
|
|
||||||
if (jsonArray.length() == 0)
|
if (jsonArray.length() == 0)
|
||||||
|
@ -386,7 +389,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
@Override
|
@Override
|
||||||
public Repository getRepositoryById(String id) throws JSONException, ResourceNotFoundException {
|
public Repository getRepositoryById(String id) throws JSONException, ResourceNotFoundException {
|
||||||
|
|
||||||
LOGGER.debug("Retrieving repositories with id : " + id);
|
logger.debug("Retrieving repositories with id : {}", id);
|
||||||
Repository repo;
|
Repository repo;
|
||||||
UriComponents uriComponents = searchDatasource("0", "100");
|
UriComponents uriComponents = searchDatasource("0", "100");
|
||||||
RequestFilter requestFilter = new RequestFilter();
|
RequestFilter requestFilter = new RequestFilter();
|
||||||
|
@ -396,7 +399,12 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
// JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
// JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
||||||
|
|
||||||
DatasourceResponse response;
|
DatasourceResponse response;
|
||||||
response = (DatasourceResponse) restTemplate.postForObject(uriComponents.toUri(), requestFilter, DatasourceResponse.class);
|
response = restTemplate.postForObject(uriComponents.toUri(), requestFilter, DatasourceResponse.class);
|
||||||
|
if (response == null) {
|
||||||
|
logger.error("The response is null!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
List<DatasourceDetails> datasources = response.getDatasourceInfo();
|
List<DatasourceDetails> datasources = response.getDatasourceInfo();
|
||||||
if (datasources.size() == 0)
|
if (datasources.size() == 0)
|
||||||
throw new ResourceNotFoundException();
|
throw new ResourceNotFoundException();
|
||||||
|
@ -409,55 +417,12 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AggregationDetails> getRepositoryAggregations(String id) throws JSONException {
|
|
||||||
|
|
||||||
LOGGER.debug("Retrieving aggregations for repository with id : " + id);
|
|
||||||
UriComponents uriComponents = getAggregationHistory(id);
|
|
||||||
|
|
||||||
String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
|
|
||||||
JSONArray aggregationInfo = new JSONObject(rs).getJSONArray("aggregationInfo");
|
|
||||||
|
|
||||||
List<AggregationDetails> aggregationHistory = new ArrayList<>(converter.toAggregationHistory(aggregationInfo));
|
|
||||||
|
|
||||||
return aggregationHistory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AggregationDetails> getRepositoryAggregations(String id, int from, int size) throws JSONException {
|
|
||||||
|
|
||||||
List<AggregationDetails> res = getRepositoryAggregations(id);
|
|
||||||
|
|
||||||
return res.subList(from, Math.min(from + size, res.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, List<AggregationDetails>> getRepositoryAggregationsByYear(String id) throws JSONException {
|
|
||||||
LOGGER.debug("Retrieving aggregations (by year) for repository with id : " + id);
|
|
||||||
|
|
||||||
List<AggregationDetails> aggregationHistory = getRepositoryAggregations(id);
|
|
||||||
Map<String, List<AggregationDetails>> aggregationByYear = new HashMap<>();
|
|
||||||
|
|
||||||
return aggregationHistory.size() == 0 ? aggregationByYear : createYearMap(aggregationHistory);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, List<AggregationDetails>> createYearMap(List<AggregationDetails> aggregationHistory) {
|
|
||||||
|
|
||||||
aggregationHistory = aggregationHistory.stream()
|
|
||||||
.sorted(Comparator.comparing(AggregationDetails::getDate).reversed())
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
return aggregationHistory.stream()
|
|
||||||
.collect(Collectors.groupingBy(AggregationDetails::getYear));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Repository> getRepositoriesByName(String name,
|
public List<Repository> getRepositoriesByName(String name,
|
||||||
String page,
|
String page,
|
||||||
String size) throws JSONException {
|
String size) throws JSONException {
|
||||||
|
|
||||||
LOGGER.debug("Retrieving repositories with official name : " + name);
|
logger.debug("Retrieving repositories with official name : {}", name);
|
||||||
UriComponents uriComponents = searchDatasource("0", "100");
|
UriComponents uriComponents = searchDatasource("0", "100");
|
||||||
RequestFilter requestFilter = new RequestFilter();
|
RequestFilter requestFilter = new RequestFilter();
|
||||||
requestFilter.setOfficialname(name);
|
requestFilter.setOfficialname(name);
|
||||||
|
@ -480,15 +445,19 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
|
|
||||||
// String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
|
// String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
|
||||||
ApiDetailsResponse rs = restTemplate.getForObject(uriComponents.toUri(), ApiDetailsResponse.class);
|
ApiDetailsResponse rs = restTemplate.getForObject(uriComponents.toUri(), ApiDetailsResponse.class);
|
||||||
|
if (rs == null) {
|
||||||
|
logger.error("The ApiDetailsResponse was null!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO STOP FILTERING OUT "sword", "rest" AND FIX UI!
|
// TODO STOP FILTERING OUT "sword", "rest" AND FIX UI!
|
||||||
List<ApiDetails> res = new ArrayList<>();
|
List<ApiDetails> res = new ArrayList<>();
|
||||||
|
|
||||||
for (ApiDetails det: rs.getApi()) {
|
for (ApiDetails det : rs.getApi()) {
|
||||||
if (!det.getProtocol().equals("sword") &&
|
String protocol = det.getProtocol();
|
||||||
!det.getProtocol().equals("rest") &&
|
if (!protocol.equals("sword") &&
|
||||||
!det.getProtocol().equals("ftp")) {
|
!protocol.equals("rest") &&
|
||||||
|
!protocol.equals("ftp")) {
|
||||||
res.add(det);
|
res.add(det);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -499,7 +468,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
@Override
|
@Override
|
||||||
public Repository addRepository(String datatype, Repository repository) throws Exception {
|
public Repository addRepository(String datatype, Repository repository) throws Exception {
|
||||||
|
|
||||||
LOGGER.debug("storing " + datatype + " repository with id: " + repository.getId());
|
logger.debug("storing '{}' repository with id: {}", datatype, repository.getId());
|
||||||
|
|
||||||
repository.setActivationId(UUID.randomUUID().toString());
|
repository.setActivationId(UUID.randomUUID().toString());
|
||||||
repository.setCollectedfrom("infrastruct_::openaire");
|
repository.setCollectedfrom("infrastruct_::openaire");
|
||||||
|
@ -538,10 +507,10 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
} catch (HttpClientErrorException e) {
|
} catch (HttpClientErrorException e) {
|
||||||
couId = registryCalls.getCouId(newRoleName);
|
couId = registryCalls.getCouId(newRoleName);
|
||||||
if (couId == null) {
|
if (couId == null) {
|
||||||
LOGGER.error(String.format("Could not create role '%s'", newRoleName), e);
|
logger.error(String.format("Could not create role '%s'", newRoleName), e);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error(String.format("Could not create role '%s'", newRoleName), e);
|
logger.error(String.format("Could not create role '%s'", newRoleName), e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,19 +518,12 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
Integer coPersonId = registryCalls.getCoPersonIdByIdentifier();
|
Integer coPersonId = registryCalls.getCoPersonIdByIdentifier();
|
||||||
if (couId != null) {
|
if (couId != null) {
|
||||||
Integer role = registryCalls.getRoleId(coPersonId, couId);
|
Integer role = registryCalls.getRoleId(coPersonId, couId);
|
||||||
try {
|
registryCalls.assignMemberRole(coPersonId, couId, role);
|
||||||
registryCalls.assignMemberRole(coPersonId, couId, role);
|
|
||||||
|
|
||||||
// Add role to current user authorities
|
|
||||||
authoritiesUpdater.addRole(roleMappingService.convertRepoIdToAuthority(repository.getId()));
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.debug("Exception on assign role to user during add repository", e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Add role to current user authorities
|
||||||
|
authoritiesUpdater.addRole(roleMappingService.convertRepoIdToAuthority(repository.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return repository;
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -574,20 +536,19 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
|
|
||||||
// FIXME: problematic
|
// FIXME: problematic
|
||||||
// String json_repository = converter.toJson(repository);
|
// String json_repository = converter.toJson(repository);
|
||||||
// LOGGER.debug("JSON to add(update) -> " + json_repository);
|
// logger.debug("JSON to add(update) -> " + json_repository);
|
||||||
|
|
||||||
HttpEntity<Repository> httpEntity = new HttpEntity<>(repository, httpHeaders); // TODO: check if it works (Repository contains extra fields)
|
HttpEntity<Repository> httpEntity = new HttpEntity<>(repository, httpHeaders); // TODO: check if it works (Repository contains extra fields)
|
||||||
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(), HttpMethod.POST, httpEntity, ResponseEntity.class);
|
ResponseEntity<ResponseEntity> responseEntity = restTemplate.exchange(uriComponents.toUri(), HttpMethod.POST, httpEntity, ResponseEntity.class);
|
||||||
|
|
||||||
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
|
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
|
||||||
try {
|
emailUtils.sendUserRegistrationEmail(repository, authentication);
|
||||||
emailUtils.sendUserRegistrationEmail(repository, authentication);
|
emailUtils.sendAdminRegistrationEmail(repository, authentication);
|
||||||
emailUtils.sendAdminRegistrationEmail(repository, authentication);
|
} else {
|
||||||
} catch (Exception e) {
|
Object responseBody = responseEntity.getBody();
|
||||||
LOGGER.error("Error sending email", e);
|
if (responseBody != null)
|
||||||
}
|
logger.error("Error updating repository: {}", responseBody);
|
||||||
} else
|
}
|
||||||
LOGGER.error("Error storing repository: " + responseEntity.getBody().toString());
|
|
||||||
|
|
||||||
return repository;
|
return repository;
|
||||||
}
|
}
|
||||||
|
@ -601,21 +562,19 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
|
|
||||||
// FIXME: problematic
|
// FIXME: problematic
|
||||||
// String json_repository = converter.toJson(repository);
|
// String json_repository = converter.toJson(repository);
|
||||||
// LOGGER.debug("JSON to update -> " + json_repository);
|
// logger.debug("JSON to update -> " + json_repository);
|
||||||
|
|
||||||
HttpEntity<Repository> httpEntity = new HttpEntity<>(repository, httpHeaders);
|
HttpEntity<Repository> httpEntity = new HttpEntity<>(repository, httpHeaders);
|
||||||
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(), HttpMethod.POST, httpEntity
|
ResponseEntity<ResponseEntity> responseEntity = restTemplate.exchange(uriComponents.toUri(), HttpMethod.POST, httpEntity, ResponseEntity.class);
|
||||||
, ResponseEntity.class);
|
|
||||||
|
|
||||||
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
|
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
|
||||||
try {
|
emailUtils.sendUserUpdateRepositoryInfoEmail(repository, authentication);
|
||||||
emailUtils.sendUserUpdateRepositoryInfoEmail(repository, authentication);
|
emailUtils.sendAdminUpdateRepositoryInfoEmail(repository, authentication);
|
||||||
emailUtils.sendAdminUpdateRepositoryInfoEmail(repository, authentication);
|
} else {
|
||||||
} catch (Exception e) {
|
Object responseBody = responseEntity.getBody();
|
||||||
LOGGER.error("Error sending emails: " + e);
|
if (responseBody != null)
|
||||||
}
|
logger.error("Error updating repository: {}", responseBody);
|
||||||
} else
|
}
|
||||||
LOGGER.debug(responseEntity.getBody().toString());
|
|
||||||
|
|
||||||
return repository;
|
return repository;
|
||||||
}
|
}
|
||||||
|
@ -634,17 +593,15 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
.encode();
|
.encode();
|
||||||
// String json_repository = converter.toJson(repository);
|
// String json_repository = converter.toJson(repository);
|
||||||
HttpEntity<Repository> httpEntity = new HttpEntity<>(repository, httpHeaders);
|
HttpEntity<Repository> httpEntity = new HttpEntity<>(repository, httpHeaders);
|
||||||
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(), HttpMethod.POST, httpEntity, ResponseEntity.class);
|
ResponseEntity<ResponseEntity> responseEntity = restTemplate.exchange(uriComponents.toUri(), HttpMethod.POST, httpEntity, ResponseEntity.class);
|
||||||
|
|
||||||
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
|
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
|
||||||
try {
|
emailUtils.sendUserRegistrationEmail(repository, authentication);
|
||||||
emailUtils.sendUserRegistrationEmail(repository, authentication);
|
emailUtils.sendAdminRegistrationEmail(repository, authentication);
|
||||||
emailUtils.sendAdminRegistrationEmail(repository, authentication);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.error("Error sending emails: " + e);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
LOGGER.debug(responseEntity.getBody().toString());
|
Object responseBody = responseEntity.getBody();
|
||||||
|
if (responseBody != null)
|
||||||
|
logger.error("Error storing repository: {}", responseBody);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -655,14 +612,16 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
.fromHttpUrl(baseAddress + "/ds/api/")
|
.fromHttpUrl(baseAddress + "/ds/api/")
|
||||||
.path("/{id}")
|
.path("/{id}")
|
||||||
.build().expand(id).encode();
|
.build().expand(id).encode();
|
||||||
LOGGER.debug(uriComponents.toUri());
|
logger.debug("{}", uriComponents.toUri());
|
||||||
restTemplate.delete(uriComponents.toUri());
|
restTemplate.delete(uriComponents.toUri());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RepositoryInterface addRepositoryInterface(String datatype,
|
public RepositoryInterface addRepositoryInterface(String datatype,
|
||||||
String repoId,
|
String repoId,
|
||||||
String comment, RepositoryInterface repositoryInterface) throws Exception {
|
String comment,
|
||||||
|
RepositoryInterface repositoryInterface,
|
||||||
|
String desiredCompatibilityLevel) throws Exception {
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
Repository e = this.getRepositoryById(repoId);
|
Repository e = this.getRepositoryById(repoId);
|
||||||
repositoryInterface = createRepositoryInterface(e, repositoryInterface, datatype);
|
repositoryInterface = createRepositoryInterface(e, repositoryInterface, datatype);
|
||||||
|
@ -677,14 +636,15 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
|
|
||||||
restTemplate.postForObject(uriComponents.toUri(), httpEntity, String.class);
|
restTemplate.postForObject(uriComponents.toUri(), httpEntity, String.class);
|
||||||
|
|
||||||
try {
|
emailUtils.sendAdminRegisterInterfaceEmail(e, comment, repositoryInterface, authentication);
|
||||||
emailUtils.sendAdminRegisterInterfaceEmail(e, comment, repositoryInterface, authentication);
|
emailUtils.sendUserRegisterInterfaceEmail(e, comment, repositoryInterface, authentication);
|
||||||
emailUtils.sendUserRegisterInterfaceEmail(e, comment, repositoryInterface, authentication);
|
|
||||||
} catch (Exception ex) {
|
if (desiredCompatibilityLevel != null && (repositoryInterface.getCompatibility() == null || !repositoryInterface.getCompatibility().equals(desiredCompatibilityLevel))) {
|
||||||
LOGGER.error("Error sending emails: " + ex);
|
InterfaceComplianceRequest request = new InterfaceComplianceRequest(repoId, repositoryInterface.getId(), desiredCompatibilityLevel);
|
||||||
|
interfaceComplianceService.create(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
submitInterfaceValidation(e, getAuthenticatedUser().getEmail(), repositoryInterface, false);
|
submitInterfaceValidation(e, getAuthenticatedUser().getEmail(), repositoryInterface, false, repositoryInterface.getCompatibility());
|
||||||
|
|
||||||
return repositoryInterface;
|
return repositoryInterface;
|
||||||
}
|
}
|
||||||
|
@ -692,41 +652,43 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
@Override
|
@Override
|
||||||
public RepositoryInterface updateRepositoryInterface(String repoId,
|
public RepositoryInterface updateRepositoryInterface(String repoId,
|
||||||
String comment,
|
String comment,
|
||||||
RepositoryInterface repositoryInterface) throws Exception {
|
RepositoryInterface repositoryInterface,
|
||||||
|
String desiredCompatibilityLevel) throws Exception {
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
this.updateBaseUrl(repoId, repositoryInterface.getId(), repositoryInterface.getBaseurl());
|
Repository repository = this.getRepositoryById(repoId);
|
||||||
this.updateCompliance(repoId, repositoryInterface.getId(), repositoryInterface.getCompatibility());
|
|
||||||
this.updateValidationSet(repoId, repositoryInterface.getId(), repositoryInterface.getAccessSet());
|
this.updateValidationSet(repoId, repositoryInterface.getId(), repositoryInterface.getAccessSet());
|
||||||
|
|
||||||
Repository repository = this.getRepositoryById(repoId);
|
emailUtils.sendAdminUpdateInterfaceEmail(repository, comment, repositoryInterface, authentication);
|
||||||
try {
|
emailUtils.sendUserUpdateInterfaceEmail(repository, comment, repositoryInterface, authentication);
|
||||||
try {
|
|
||||||
emailUtils.sendAdminUpdateInterfaceEmail(repository, comment, repositoryInterface, authentication);
|
if (desiredCompatibilityLevel != null && (repositoryInterface.getCompatibility() == null || !repositoryInterface.getCompatibility().equals(desiredCompatibilityLevel))) {
|
||||||
emailUtils.sendUserUpdateInterfaceEmail(repository, comment, repositoryInterface, authentication);
|
InterfaceComplianceRequest request = new InterfaceComplianceRequest(repoId, repositoryInterface.getId(), desiredCompatibilityLevel);
|
||||||
} catch (Exception e) {
|
interfaceComplianceService.create(request);
|
||||||
LOGGER.error("Error sending emails: " + e);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.warn("Could not send emails", e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
submitInterfaceValidation(getRepositoryById(repoId), getAuthenticatedUser().getEmail(), repositoryInterface, true);
|
submitInterfaceValidation(getRepositoryById(repoId), getAuthenticatedUser().getEmail(), repositoryInterface, true, desiredCompatibilityLevel);
|
||||||
|
|
||||||
return repositoryInterface;
|
return repositoryInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateInterfaceCompliance(String repositoryId, String repositoryInterfaceId, String compliance) {
|
||||||
|
this.updateCompliance(repositoryId, repositoryInterfaceId, compliance);
|
||||||
|
}
|
||||||
|
|
||||||
private User getAuthenticatedUser() {
|
private User getAuthenticatedUser() {
|
||||||
return User.from(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo());
|
return User.from(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void submitInterfaceValidation(Repository repo, String userEmail, RepositoryInterface iFace, boolean updateExisting) throws ValidatorServiceException {
|
private void submitInterfaceValidation(Repository repo, String userEmail, RepositoryInterface iFace, boolean updateExisting, String desiredCompatibilityLevel) throws ValidatorServiceException {
|
||||||
JobForValidation job = new JobForValidation();
|
JobForValidation job = new JobForValidation();
|
||||||
|
|
||||||
job.setActivationId(UUID.randomUUID().toString());
|
job.setActivationId(UUID.randomUUID().toString());
|
||||||
job.setAdminEmails(Collections.singletonList(this.adminEmail));
|
job.setAdminEmails(Collections.singletonList(this.adminEmail));
|
||||||
job.setBaseUrl(iFace.getBaseurl());
|
job.setBaseUrl(iFace.getBaseurl());
|
||||||
job.setDatasourceId(repo.getId());
|
job.setDatasourceId(repo.getId());
|
||||||
job.setDesiredCompatibilityLevel(iFace.getCompatibilityOverride());
|
job.setDesiredCompatibilityLevel(desiredCompatibilityLevel);
|
||||||
job.setInterfaceId(iFace.getId());
|
job.setInterfaceId(iFace.getId());
|
||||||
job.setOfficialName(repo.getOfficialname());
|
job.setOfficialName(repo.getOfficialname());
|
||||||
job.setRepoType(repo.getEoscDatasourceType());
|
job.setRepoType(repo.getEoscDatasourceType());
|
||||||
|
@ -745,7 +707,12 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
|
|
||||||
iFace.setDatasource(repo.getId());
|
iFace.setDatasource(repo.getId());
|
||||||
iFace.setContentdescription("metadata");
|
iFace.setContentdescription("metadata");
|
||||||
iFace.setCompatibility("UNKNOWN");
|
|
||||||
|
// TODO: double check me
|
||||||
|
logger.warn("Compatibility level: {}", iFace.getCompatibility());
|
||||||
|
if (iFace.getCompatibility() == null || iFace.getCompatibility().equals("")) {
|
||||||
|
iFace.setCompatibility("UNKNOWN");
|
||||||
|
}
|
||||||
|
|
||||||
if (datatype.equals("re3data"))
|
if (datatype.equals("re3data"))
|
||||||
iFace.setAccessFormat("oai_datacite");
|
iFace.setAccessFormat("oai_datacite");
|
||||||
|
@ -770,8 +737,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
iFace.setMetadataIdentifierPath("//*[local-name()='header']/*[local-name()='identifier']");
|
iFace.setMetadataIdentifierPath("//*[local-name()='header']/*[local-name()='identifier']");
|
||||||
iFace.setId("api_________::" + repo.getId() + "::" + UUID.randomUUID().toString().substring(0, 8));
|
iFace.setId("api_________::" + repo.getId() + "::" + UUID.randomUUID().toString().substring(0, 8));
|
||||||
if (iFace.getAccessSet() == null || iFace.getAccessSet().isEmpty()) {
|
if (iFace.getAccessSet() == null || iFace.getAccessSet().isEmpty()) {
|
||||||
LOGGER.debug("set is empty: " + iFace.getAccessSet());
|
logger.debug("set is empty: {}", iFace.getAccessSet());
|
||||||
// iFace.removeAccessSet();
|
|
||||||
iFace.setAccessSet("none");
|
iFace.setAccessSet("none");
|
||||||
}
|
}
|
||||||
return iFace;
|
return iFace;
|
||||||
|
@ -779,7 +745,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getDnetCountries() {
|
public List<String> getDnetCountries() {
|
||||||
LOGGER.debug("Getting dnet-countries!");
|
logger.debug("Getting dnet-countries!");
|
||||||
return converter.readFile("countries.txt");
|
return converter.readFile("countries.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -805,7 +771,8 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
|
|
||||||
RequestFilter requestFilter = new RequestFilter();
|
RequestFilter requestFilter = new RequestFilter();
|
||||||
requestFilter.setRegisteredby(userEmail);
|
requestFilter.setRegisteredby(userEmail);
|
||||||
return Arrays.asList(restTemplate.postForObject(uriComponents.toUri(), requestFilter, String[].class));
|
Object result = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String[].class);
|
||||||
|
return (result != null) ? Collections.singletonList(result.toString()) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vocabulary getVocabulary(String vocName) {
|
private Vocabulary getVocabulary(String vocName) {
|
||||||
|
@ -820,7 +787,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getCompatibilityClasses(String mode) {
|
public Map<String, String> getCompatibilityClasses(String mode) {
|
||||||
|
|
||||||
LOGGER.debug("Getting compatibility classes for mode: " + mode);
|
logger.debug("Getting compatibility classes for mode: {}", mode);
|
||||||
Map<String, String> retMap = new HashMap<String, String>();
|
Map<String, String> retMap = new HashMap<String, String>();
|
||||||
|
|
||||||
Map<String, String> compatibilityClasses = this.getVocabulary("dnet:compatibilityLevel").getAsMap();
|
Map<String, String> compatibilityClasses = this.getVocabulary("dnet:compatibilityLevel").getAsMap();
|
||||||
|
@ -829,18 +796,17 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_ALL))
|
if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_ALL))
|
||||||
return compatibilityClasses;
|
return compatibilityClasses;
|
||||||
else if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_RE3DATA)) {
|
else if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_RE3DATA)) {
|
||||||
if (entry.getKey().matches("^openaire[1-9].0_data$")) {
|
if (ValidatorServiceImpl.OPENAIRE_DATA_REGEX.matcher(entry.getKey()).matches()) {
|
||||||
retMap.put(entry.getKey(), entry.getValue());
|
retMap.put(entry.getKey(), entry.getValue());
|
||||||
foundData = true;
|
foundData = true;
|
||||||
}
|
}
|
||||||
}
|
} else if (mode.equalsIgnoreCase("cris")) {
|
||||||
else if (mode.equalsIgnoreCase("cris")) {
|
|
||||||
if (entry.getKey().contains("openaire-cris")) {
|
if (entry.getKey().contains("openaire-cris")) {
|
||||||
retMap.put(entry.getKey(), entry.getValue());
|
retMap.put(entry.getKey(), entry.getValue());
|
||||||
foundData = true;
|
foundData = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (entry.getKey().matches("^openaire[1-9].0$") || entry.getKey().equals("driver"))
|
if (ValidatorServiceImpl.OPENAIRE_OR_DRIVER_REGEX.matcher(entry.getKey()).matches())
|
||||||
retMap.put(entry.getKey(), entry.getValue());
|
retMap.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -855,7 +821,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getDatasourceClasses(String mode) {
|
public Map<String, String> getDatasourceClasses(String mode) {
|
||||||
|
|
||||||
LOGGER.debug("Getting datasource classes for mode: " + mode);
|
logger.debug("Getting datasource classes for mode: {}", mode);
|
||||||
|
|
||||||
Map<String, String> retMap = new HashMap<String, String>();
|
Map<String, String> retMap = new HashMap<String, String>();
|
||||||
|
|
||||||
|
@ -916,7 +882,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
return metricsInfo;
|
return metricsInfo;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while getting metrics info for repository: ", e);
|
logger.error("Error while getting metrics info for repository: ", e);
|
||||||
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -925,31 +891,30 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
public Map<String, String> getListLatestUpdate(String mode) throws JSONException {
|
public Map<String, String> getListLatestUpdate(String mode) throws JSONException {
|
||||||
Map<String, String> dates = new HashMap<>();
|
Map<String, String> dates = new HashMap<>();
|
||||||
if (mode.equals("repository")) {
|
if (mode.equals("repository")) {
|
||||||
dates.put("opendoar", converter.toString(getRepositoryInterface("openaire____::opendoar").get(0).getLastCollectionDate()));
|
dates.put("opendoar", DateUtils.toString(getRepositoryInterface("openaire____::opendoar").get(0).getLastCollectionDate()));
|
||||||
dates.put("fairsharing", converter.toString(getRepositoryInterface("openaire____::fairsharing").get(0).getLastCollectionDate()));
|
dates.put("fairsharing", DateUtils.toString(getRepositoryInterface("openaire____::fairsharing").get(0).getLastCollectionDate()));
|
||||||
// create re3data last collection date
|
// create re3data last collection date
|
||||||
// dates.put("re3data", converter.toString(getRepositoryInterface("openaire____::re3data").get(1).getLastCollectionDate()));
|
// dates.put("re3data", converter.toString(getRepositoryInterface("openaire____::re3data").get(1).getLastCollectionDate()));
|
||||||
List<RepositoryInterface> re3interfaces = getRepositoryInterface("openaire____::re3data");
|
List<RepositoryInterface> re3interfaces = getRepositoryInterface("openaire____::re3data");
|
||||||
String re3Date = null;
|
String re3Date = null;
|
||||||
for (RepositoryInterface interf : re3interfaces) {
|
for (RepositoryInterface interf : re3interfaces) {
|
||||||
if (interf.getLastCollectionDate() != null) {
|
if (interf.getLastCollectionDate() != null) {
|
||||||
re3Date = converter.toString(interf.getLastCollectionDate());
|
re3Date = DateUtils.toString(interf.getLastCollectionDate());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dates.put("re3data", re3Date);
|
dates.put("re3data", re3Date);
|
||||||
|
|
||||||
return dates;
|
return dates;
|
||||||
}
|
} else if (mode.equals("cris"))
|
||||||
else if (mode.equals("cris"))
|
return Collections.singletonMap("lastCollectionDate", DateUtils.toString(getRepositoryInterface("eurocrisdris::dris").get(0).getLastCollectionDate()));
|
||||||
return Collections.singletonMap("lastCollectionDate", converter.toString(getRepositoryInterface("eurocrisdris::dris").get(0).getLastCollectionDate()));
|
|
||||||
else if (mode.equals("opendoar")) // TODO: remove this and else clause
|
else if (mode.equals("opendoar")) // TODO: remove this and else clause
|
||||||
return Collections.singletonMap("lastCollectionDate", converter.toString(getRepositoryInterface("openaire____::" + mode).get(0).getLastCollectionDate()));
|
return Collections.singletonMap("lastCollectionDate", DateUtils.toString(getRepositoryInterface("openaire____::" + mode).get(0).getLastCollectionDate()));
|
||||||
else
|
else
|
||||||
/*
|
/*
|
||||||
* first api of re3data has null value on collection date
|
* first api of re3data has null value on collection date
|
||||||
* */
|
* */
|
||||||
return Collections.singletonMap("lastCollectionDate", converter.toString(getRepositoryInterface("openaire____::" + mode).get(0).getLastCollectionDate()));
|
return Collections.singletonMap("lastCollectionDate", DateUtils.toString(getRepositoryInterface("openaire____::" + mode).get(0).getLastCollectionDate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateValidationSet(String repositoryId, String repositoryInterfaceId, String validationSet) throws Exception {
|
private void updateValidationSet(String repositoryId, String repositoryInterfaceId, String validationSet) throws Exception {
|
||||||
|
@ -1014,12 +979,6 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private UriComponents getAggregationHistory(String repoId) {
|
|
||||||
return UriComponentsBuilder
|
|
||||||
.fromHttpUrl(baseAddress + "/ds/aggregationhistory/")
|
|
||||||
.path(repoId)
|
|
||||||
.build().expand(repoId).encode();
|
|
||||||
}
|
|
||||||
|
|
||||||
private UriComponents searchDatasource(String page, String size) {
|
private UriComponents searchDatasource(String page, String size) {
|
||||||
|
|
||||||
|
@ -1031,7 +990,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
.build().expand(page, size).encode();
|
.build().expand(page, size).encode();
|
||||||
}
|
}
|
||||||
|
|
||||||
private UriComponents searchSnipperDatasource(String page, String size) {
|
private UriComponents searchSnippetDatasource(String page, String size) {
|
||||||
|
|
||||||
return UriComponentsBuilder
|
return UriComponentsBuilder
|
||||||
.fromHttpUrl(baseAddress + "/ds/searchsnippet/")
|
.fromHttpUrl(baseAddress + "/ds/searchsnippet/")
|
||||||
|
|
|
@ -1,17 +1,27 @@
|
||||||
package eu.dnetlib.repo.manager.service;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.service.customHystrixCommands.*;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.client.RestClientException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
import org.springframework.web.util.UriComponents;
|
||||||
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Service("statsService")
|
@Service("statsService")
|
||||||
public class StatsServiceImpl implements StatsService {
|
public class StatsServiceImpl implements StatsService {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(StatsServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RestTemplate restTemplate;
|
RestTemplate restTemplate;
|
||||||
|
|
||||||
|
@ -24,27 +34,215 @@ public class StatsServiceImpl implements StatsService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map getStatistics() {
|
public Map getStatistics() {
|
||||||
|
|
||||||
UsageStatsTotalHystrixCommand usageStatsTotalHystrixCommand = new UsageStatsTotalHystrixCommand(usagestatsEvents,restTemplate);
|
|
||||||
DataRepositoriesHystrixCommand dataRepositoriesHystrixCommand = new DataRepositoriesHystrixCommand(baseAddress,restTemplate);
|
|
||||||
AggregatorsHystrixCommand aggregatorsHystrixCommand = new AggregatorsHystrixCommand(baseAddress,restTemplate);
|
|
||||||
LiteratureHystrixCommand literatureHystrixCommand = new LiteratureHystrixCommand(baseAddress,restTemplate);
|
|
||||||
JournalHystrixCommand journalHystrixCommand = new JournalHystrixCommand(baseAddress,restTemplate);
|
|
||||||
PublicationHystrixCommand publicationHystrixCommand = new PublicationHystrixCommand(baseAddress,restTemplate);
|
|
||||||
DatasetsHystrixCommand datasetsHystrixCommand = new DatasetsHystrixCommand(baseAddress,restTemplate);
|
|
||||||
SoftwareHystrixCommand softwareHystrixCommand = new SoftwareHystrixCommand(baseAddress,restTemplate);
|
|
||||||
LastYearUsageStatsHystrixCommand lastYearUsageStatsHystrixCommand = new LastYearUsageStatsHystrixCommand(usagestatsBaseAddress,restTemplate);
|
|
||||||
|
|
||||||
Map<String,Object> stats = new HashMap<>();
|
Map<String,Object> stats = new HashMap<>();
|
||||||
stats.put("aggregators",aggregatorsHystrixCommand.execute());
|
stats.put("aggregators", this.getAggregatorsStats());
|
||||||
stats.put("dataRepositories",dataRepositoriesHystrixCommand.execute());
|
stats.put("dataRepositories", this.getDataRepositoriesMetadata());
|
||||||
stats.put("literature",literatureHystrixCommand.execute());
|
stats.put("literature", this.getLiteratureStats());
|
||||||
stats.put("journal",journalHystrixCommand.execute());
|
stats.put("journal", this.getJournalsStats());
|
||||||
stats.put("publications",publicationHystrixCommand.execute());
|
stats.put("publications", this.getPublicationStats());
|
||||||
stats.put("datasets",datasetsHystrixCommand.execute());
|
stats.put("datasets", this.getDatasetsStats());
|
||||||
stats.put("software",softwareHystrixCommand.execute());
|
stats.put("software", this.getSoftwareStats());
|
||||||
stats.put("lastYearUsagestats", lastYearUsageStatsHystrixCommand.execute());
|
stats.put("lastYearUsagestats", this.getLastYearUsageStats());
|
||||||
stats.put("usagestats",usageStatsTotalHystrixCommand.execute());
|
stats.put("usagestats", this.getUsageStatsTotal());
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getAggregatorsStats()
|
||||||
|
{
|
||||||
|
String url = baseAddress + "/resources" +
|
||||||
|
"?query= " +
|
||||||
|
" oaftype exact datasource and " +
|
||||||
|
" ( datasourcetypename exact Institutional Repository Aggregator " +
|
||||||
|
" or datasourcetypename exact Publication Repository Aggregator )";
|
||||||
|
|
||||||
|
UriComponents uriComponents = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(url)
|
||||||
|
.queryParam("page", 0)
|
||||||
|
.queryParam("size", 0)
|
||||||
|
.queryParam("format", "json")
|
||||||
|
.build().encode();
|
||||||
|
|
||||||
|
try {
|
||||||
|
ResponseEntity<Map> rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||||
|
Map metadata = (Map) ((Map<?, ?>) Objects.requireNonNull(rs.getBody())).get("meta");
|
||||||
|
return String.valueOf(metadata.get("total"));
|
||||||
|
} catch ( RestClientException rce ) {
|
||||||
|
logger.error(rce.getMessage());
|
||||||
|
return null;
|
||||||
|
} catch ( Exception e ) {
|
||||||
|
logger.error("", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getDataRepositoriesMetadata()
|
||||||
|
{
|
||||||
|
String url = baseAddress + "/resources" +
|
||||||
|
"?query= " +
|
||||||
|
" oaftype exact datasource and " +
|
||||||
|
" datasourcetypename exact Data Repository ";
|
||||||
|
|
||||||
|
return getMetadataTotals(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getLiteratureStats()
|
||||||
|
{
|
||||||
|
String url = baseAddress + "/resources" +
|
||||||
|
"?query= " +
|
||||||
|
" oaftype exact datasource and " +
|
||||||
|
" ( datasourcetypename exact Institutional Repository " +
|
||||||
|
" or datasourcetypename exact Publication Repository )";
|
||||||
|
|
||||||
|
return getMetadataTotals(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getJournalsStats()
|
||||||
|
{
|
||||||
|
String url = baseAddress + "/resources" +
|
||||||
|
"?query= " +
|
||||||
|
" oaftype exact datasource and " +
|
||||||
|
" datasourcetypename exact Journal";
|
||||||
|
|
||||||
|
return getMetadataTotals(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getPublicationStats()
|
||||||
|
{
|
||||||
|
String url = baseAddress + "/publications/count";
|
||||||
|
|
||||||
|
return getCommonStats(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getDatasetsStats()
|
||||||
|
{
|
||||||
|
String url = baseAddress + "/datasets/count";
|
||||||
|
|
||||||
|
return getCommonStats(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getSoftwareStats()
|
||||||
|
{
|
||||||
|
String url = baseAddress + "/software/count";
|
||||||
|
|
||||||
|
return getCommonStats(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Map<String,Object> getLastYearUsageStats()
|
||||||
|
{
|
||||||
|
UriComponents uriComponents = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(usagestatsBaseAddress + "/totals")
|
||||||
|
.build().encode();
|
||||||
|
|
||||||
|
try {
|
||||||
|
ResponseEntity<Map> rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||||
|
|
||||||
|
List yearly_stats = (List) ((Map<?, ?>) Objects.requireNonNull(rs.getBody())).get("yearly_stats");
|
||||||
|
Map lastYear = (Map) yearly_stats.get(yearly_stats.size() - 2);
|
||||||
|
Integer downloads = (Integer) lastYear.get("downloads");
|
||||||
|
Integer views = (Integer) lastYear.get("views");
|
||||||
|
Integer year = (Integer) lastYear.get("year");
|
||||||
|
|
||||||
|
Map<String, Object> usagestats = new HashMap<>();
|
||||||
|
usagestats.put("number", String.valueOf(downloads + views));
|
||||||
|
usagestats.put("year", year);
|
||||||
|
return usagestats;
|
||||||
|
} catch ( RestClientException rce ) {
|
||||||
|
logger.error(rce.getMessage());
|
||||||
|
return null;
|
||||||
|
} catch ( Exception e ) {
|
||||||
|
logger.error("", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Integer getUsageStatsTotal()
|
||||||
|
{
|
||||||
|
UriComponents uriComponents = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(usagestatsEvents)
|
||||||
|
.build().encode();
|
||||||
|
|
||||||
|
try {
|
||||||
|
ResponseEntity<Map> rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||||
|
Map statsTotals = (Map) ((Map<?, ?>) Objects.requireNonNull(rs.getBody())).get("totals");
|
||||||
|
if ( statsTotals == null ) {
|
||||||
|
logger.error("The statsTotals was null!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO - Will we ever need the following lines?
|
||||||
|
// String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
|
||||||
|
// JSONObject resultSet = new JSONObject(rs);
|
||||||
|
// JSONObject totals = resultSet.getJSONObject("totals");
|
||||||
|
|
||||||
|
return (Integer) statsTotals.get("events");
|
||||||
|
} catch ( RestClientException rce ) {
|
||||||
|
logger.error(rce.getMessage());
|
||||||
|
return null;
|
||||||
|
} catch ( Exception e ) {
|
||||||
|
logger.error("", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getMetadataTotals(String url) {
|
||||||
|
UriComponents uriComponents = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(url)
|
||||||
|
.queryParam("page", 0)
|
||||||
|
.queryParam("size", 0)
|
||||||
|
.queryParam("format", "json")
|
||||||
|
.build().encode();
|
||||||
|
|
||||||
|
try {
|
||||||
|
ResponseEntity<Map> rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||||
|
Map metadata = (Map) ((Map<?, ?>) Objects.requireNonNull(rs.getBody())).get("meta");
|
||||||
|
if ( metadata == null ) {
|
||||||
|
logger.error("The metadata was null!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return String.valueOf(metadata.get("total"));
|
||||||
|
} catch ( RestClientException rce ) {
|
||||||
|
logger.error(rce.getMessage());
|
||||||
|
return null;
|
||||||
|
} catch ( Exception e ) {
|
||||||
|
logger.error("", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getCommonStats(String url) {
|
||||||
|
UriComponents uriComponents = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(url)
|
||||||
|
.queryParam("page", 0)
|
||||||
|
.queryParam("size", 0)
|
||||||
|
.queryParam("format", "json")
|
||||||
|
.build().encode();
|
||||||
|
|
||||||
|
try {
|
||||||
|
ResponseEntity<Map> rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
||||||
|
Map stats = (Map<?, ?>) rs.getBody();
|
||||||
|
if ( stats == null ) {
|
||||||
|
logger.error("The stats was null!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return String.valueOf(stats.get("total"));
|
||||||
|
} catch ( RestClientException rce ) {
|
||||||
|
logger.error(rce.getMessage());
|
||||||
|
return null;
|
||||||
|
} catch ( Exception e ) {
|
||||||
|
logger.error("", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
package eu.dnetlib.repo.manager.service;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
|
import eu.dnetlib.usagestats.sushilite.domain.Customer;
|
||||||
import eu.dnetlib.usagestats.sushilite.domain.ReportItem;
|
import eu.dnetlib.usagestats.sushilite.domain.ReportItem;
|
||||||
import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper;
|
import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.ParameterizedTypeReference;
|
import org.springframework.core.ParameterizedTypeReference;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.client.RestClientException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
|
@ -22,7 +27,7 @@ public class SushiliteServiceImpl implements SushiliteService {
|
||||||
@Value("${services.provide.usagestats.sushiliteEndpoint}")
|
@Value("${services.provide.usagestats.sushiliteEndpoint}")
|
||||||
private String usagestatsSushiliteEndpoint;
|
private String usagestatsSushiliteEndpoint;
|
||||||
|
|
||||||
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger.getLogger(SushiliteServiceImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(SushiliteServiceImpl.class);
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,65 +45,79 @@ public class SushiliteServiceImpl implements SushiliteService {
|
||||||
String Granularity,
|
String Granularity,
|
||||||
String Pretty) {
|
String Pretty) {
|
||||||
|
|
||||||
//build the uri params
|
//build the uri params
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.usagestatsSushiliteEndpoint + "GetReport/")
|
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.usagestatsSushiliteEndpoint + "GetReport/")
|
||||||
.queryParam("Report", Report)
|
.queryParam("Report", Report)
|
||||||
.queryParam("Release", Release)
|
.queryParam("Release", Release)
|
||||||
.queryParam("RequestorID", RequestorID)
|
.queryParam("RequestorID", RequestorID)
|
||||||
.queryParam("BeginDate", BeginDate)
|
.queryParam("BeginDate", BeginDate)
|
||||||
.queryParam("EndDate", EndDate)
|
.queryParam("EndDate", EndDate)
|
||||||
.queryParam("RepositoryIdentifier", RepositoryIdentifier)
|
.queryParam("RepositoryIdentifier", RepositoryIdentifier)
|
||||||
.queryParam("ItemIdentifier", ItemIdentifier)
|
.queryParam("ItemIdentifier", ItemIdentifier)
|
||||||
.queryParam("ItemDataType", ItemDataType)
|
.queryParam("ItemDataType", ItemDataType)
|
||||||
.queryParam("Granularity", Granularity)
|
.queryParam("Granularity", Granularity)
|
||||||
.queryParam("Pretty", Pretty);
|
.queryParam("Pretty", Pretty);
|
||||||
|
|
||||||
//create new template engine
|
//create new restTemplate engine
|
||||||
RestTemplate template = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
||||||
|
|
||||||
ResponseEntity<ReportResponseWrapper> resp;
|
ResponseEntity<ReportResponseWrapper> resp;
|
||||||
|
|
||||||
|
try {
|
||||||
//communicate with endpoint
|
//communicate with endpoint
|
||||||
resp = template.exchange(
|
resp = restTemplate.exchange(
|
||||||
builder.build().encode().toUri(),
|
builder.build().encode().toUri(),
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
null,
|
null,
|
||||||
new ParameterizedTypeReference<ReportResponseWrapper>() {
|
new ParameterizedTypeReference<ReportResponseWrapper>() {});
|
||||||
});
|
} catch (RestClientException rce) {
|
||||||
|
logger.error("", rce);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// check remote api's response
|
// check remote api's response
|
||||||
System.out.println("sushi responded status " + resp.getStatusCode());
|
HttpStatus httpStatus = resp.getStatusCode();
|
||||||
|
if ( httpStatus != HttpStatus.OK ) {
|
||||||
|
logger.warn("Sushi cannot give us data! Responded status: " + httpStatus);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// get the items corresponding to the requested page
|
ReportResponseWrapper reportResponseWrapper = resp.getBody();
|
||||||
List<ReportItem> requestedItemList = new ArrayList<>();
|
if ( reportResponseWrapper == null ) {
|
||||||
if (resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems() != null) {
|
logger.error("The \"reportResponseWrapper\" for sushi was null!");
|
||||||
try {
|
return null;
|
||||||
int totalItems = resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems().size();
|
}
|
||||||
int size = Integer.parseInt(pageSize);
|
|
||||||
int offset = Integer.parseInt(page)*size;
|
|
||||||
|
|
||||||
if (offset < totalItems ) {
|
// get the items corresponding to the requested page
|
||||||
int upperIndex = offset+size;
|
List<ReportItem> requestedItemList = new ArrayList<>();
|
||||||
if (upperIndex > totalItems) {
|
|
||||||
upperIndex = totalItems;
|
Customer customer = reportResponseWrapper.getReportResponse().getReportWrapper().getReport().getCustomer();
|
||||||
}
|
List<ReportItem> allReportItems = customer.getReportItems();
|
||||||
requestedItemList = resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems().subList(offset,upperIndex);
|
|
||||||
|
if ( allReportItems != null) {
|
||||||
|
try {
|
||||||
|
int totalItems = allReportItems.size();
|
||||||
|
int size = Integer.parseInt(pageSize);
|
||||||
|
int offset = (Integer.parseInt(page) * size);
|
||||||
|
|
||||||
|
if (offset < totalItems ) {
|
||||||
|
int upperIndex = (offset + size);
|
||||||
|
if (upperIndex > totalItems) {
|
||||||
|
upperIndex = totalItems;
|
||||||
}
|
}
|
||||||
|
requestedItemList = allReportItems.subList(offset, upperIndex);
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
LOGGER.debug("Exception on getReportResults - trying to cast strings to integers", e);
|
|
||||||
//emailUtils.reportException(e);
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
logger.debug("Exception on getReportResults - trying to cast strings to integers", e);
|
||||||
|
//emailUtils.reportException(e);
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ReportResponseWrapper newReportResponse = resp.getBody();
|
customer.setReportItems(requestedItemList); // Setting the reportItems to the "customer"-reference, updates the "reportResponseWrapper" object.
|
||||||
newReportResponse.getReportResponse().getReportWrapper().getReport().getCustomer().setReportItems(requestedItemList);
|
|
||||||
|
|
||||||
|
return reportResponseWrapper;
|
||||||
return newReportResponse;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package eu.dnetlib.repo.manager.service;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.mitre.openid.connect.model.UserInfo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
|
@ -16,21 +18,24 @@ import java.util.stream.Collectors;
|
||||||
@Service("userService")
|
@Service("userService")
|
||||||
public class UserServiceImpl implements UserService {
|
public class UserServiceImpl implements UserService {
|
||||||
|
|
||||||
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger
|
private static final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);
|
||||||
.getLogger(UserServiceImpl.class);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Object> login() {
|
public ResponseEntity<Object> login() {
|
||||||
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||||
LOGGER.debug("User authentication : " + authentication);
|
logger.debug("User authentication : " + authentication);
|
||||||
Map<String,Object> body = new HashMap<>();
|
Map<String,Object> body = new HashMap<>();
|
||||||
body.put("sub",authentication.getSub());
|
body.put("sub",authentication.getSub());
|
||||||
if(authentication.getUserInfo().getName() == null || authentication.getUserInfo().getName().equals(""))
|
|
||||||
body.put("name",authentication.getUserInfo().getGivenName() + " " + authentication.getUserInfo().getFamilyName());
|
|
||||||
else
|
|
||||||
body.put("name",authentication.getUserInfo().getName());
|
|
||||||
|
|
||||||
body.put("email",authentication.getUserInfo().getEmail());
|
UserInfo userInfo = authentication.getUserInfo();
|
||||||
|
String userName = userInfo.getName();
|
||||||
|
|
||||||
|
if ( userName == null || userName.isEmpty() )
|
||||||
|
body.put("name", userInfo.getGivenName() + " " + userInfo.getFamilyName());
|
||||||
|
else
|
||||||
|
body.put("name", userName);
|
||||||
|
|
||||||
|
body.put("email",userInfo.getEmail());
|
||||||
List<String> roles = authentication.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList());
|
List<String> roles = authentication.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList());
|
||||||
body.put("role",roles);
|
body.put("role",roles);
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||||
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
||||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||||
import eu.dnetlib.repo.manager.domain.InterfaceInformation;
|
import eu.dnetlib.repo.manager.domain.InterfaceInformation;
|
||||||
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
|
||||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||||
|
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
|
@ -42,4 +42,6 @@ public interface ValidatorService {
|
||||||
InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException;
|
InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException;
|
||||||
|
|
||||||
List<StoredJob> getJobsSummary(String repoId, int limit) throws ValidatorServiceException, ResourceNotFoundException, JSONException;
|
List<StoredJob> getJobsSummary(String repoId, int limit) throws ValidatorServiceException, ResourceNotFoundException, JSONException;
|
||||||
|
|
||||||
|
void onComplete(String repoId, String interfaceId, String jobId, String issuerEmail, boolean isUpdate, boolean isSuccess, int scoreUsage, int scoreContent) throws Exception;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,21 @@
|
||||||
package eu.dnetlib.repo.manager.service;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||||
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
|
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||||
import eu.dnetlib.domain.functionality.validator.*;
|
import eu.dnetlib.domain.functionality.validator.Rule;
|
||||||
import eu.dnetlib.repo.manager.domain.Constants;
|
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
||||||
import eu.dnetlib.repo.manager.domain.InterfaceInformation;
|
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||||
|
import eu.dnetlib.repo.manager.domain.*;
|
||||||
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
||||||
import eu.dnetlib.repo.manager.utils.CrisValidatorUtils;
|
import eu.dnetlib.repo.manager.utils.CrisValidatorUtils;
|
||||||
import eu.dnetlib.repo.manager.utils.OaiTools;
|
import eu.dnetlib.repo.manager.utils.OaiTools;
|
||||||
import gr.uoa.di.driver.util.ServiceLocator;
|
import gr.uoa.di.driver.util.ServiceLocator;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.eurocris.openaire.cris.validator.model.Job;
|
import org.eurocris.openaire.cris.validator.model.Job;
|
||||||
import org.eurocris.openaire.cris.validator.service.JobExecutor;
|
import org.eurocris.openaire.cris.validator.service.JobExecutor;
|
||||||
import org.eurocris.openaire.cris.validator.service.MapJobDao;
|
import org.eurocris.openaire.cris.validator.service.MapJobDao;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -25,6 +27,7 @@ import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,10 +55,9 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
this.validatorServiceLocator = validatorServiceLocator;
|
this.validatorServiceLocator = validatorServiceLocator;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, List<RuleSet>> rulesetMap = new ConcurrentHashMap<String, List<RuleSet>>();
|
private final Map<String, List<RuleSet>> rulesetMap = new ConcurrentHashMap<String, List<RuleSet>>();
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger
|
private static final Logger logger = LoggerFactory.getLogger(ValidatorServiceImpl.class);
|
||||||
.getLogger(ValidatorServiceImpl.class);
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EmailUtils emailUtils;
|
private EmailUtils emailUtils;
|
||||||
|
@ -66,20 +68,30 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private MapJobDao crisJobs;
|
private MapJobDao crisJobs;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
InterfaceComplianceService interfaceComplianceService;
|
||||||
|
|
||||||
|
|
||||||
|
public static final Pattern OPENAIRE_DATA_REGEX = Pattern.compile("^openaire[1-9].0_data$");
|
||||||
|
public static final Pattern OPENAIRE_OR_DRIVER_REGEX = Pattern.compile("^(?:openaire[1-9].0|driver)$");
|
||||||
|
public static final Pattern OPENAIRE_CRIS_REGEX = Pattern.compile("^openaire[1-9].0_cris$");
|
||||||
|
public static final Pattern FAIR_REGEX = Pattern.compile(".*fair$");
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void loadRules(){
|
private void loadRules(){
|
||||||
LOGGER.debug("PostConstruct method! Load rules!");
|
logger.debug("PostConstruct method! Load rules!");
|
||||||
try {
|
try {
|
||||||
for (RuleSet ruleSet : getValidationService().getRuleSets()) {
|
for (RuleSet ruleSet : getValidationService().getRuleSets()) {
|
||||||
if (ruleSet.getVisibility() != null && ruleSet.getVisibility().contains("development")) {
|
if (ruleSet.getVisibility() != null && ruleSet.getVisibility().contains("development")) {
|
||||||
String key = "";
|
String key = "";
|
||||||
if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0_data$"))
|
String guidelinesAcronym = ruleSet.getGuidelinesAcronym();
|
||||||
|
if ( OPENAIRE_DATA_REGEX.matcher(guidelinesAcronym).matches() )
|
||||||
key = Constants.VALIDATION_MODE_DATA;
|
key = Constants.VALIDATION_MODE_DATA;
|
||||||
else if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0$") || ruleSet.getGuidelinesAcronym().equals("driver"))
|
else if ( OPENAIRE_OR_DRIVER_REGEX.matcher(guidelinesAcronym).matches() )
|
||||||
key = Constants.VALIDATION_MODE_LITERATURE;
|
key = Constants.VALIDATION_MODE_LITERATURE;
|
||||||
else if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0_cris$"))
|
else if ( OPENAIRE_CRIS_REGEX.matcher(guidelinesAcronym).matches() )
|
||||||
key = Constants.VALIDATION_MODE_CRIS;
|
key = Constants.VALIDATION_MODE_CRIS;
|
||||||
else if (ruleSet.getGuidelinesAcronym().matches(".*fair$"))
|
else if ( FAIR_REGEX.matcher(guidelinesAcronym).matches() )
|
||||||
key = Constants.VALIDATION_MODE_FAIR;
|
key = Constants.VALIDATION_MODE_FAIR;
|
||||||
|
|
||||||
if (rulesetMap.containsKey(key))
|
if (rulesetMap.containsKey(key))
|
||||||
|
@ -121,7 +133,7 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
} catch (ValidatorServiceException e) {
|
} catch (ValidatorServiceException e) {
|
||||||
LOGGER.error(e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -129,19 +141,15 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
@Override
|
@Override
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||||
public JobForValidation submitJobForValidation(JobForValidation jobForValidation) throws ValidatorServiceException {
|
public JobForValidation submitJobForValidation(JobForValidation jobForValidation) throws ValidatorServiceException {
|
||||||
LOGGER.debug("Submit job for validation with id : " + jobForValidation.getDatasourceId());
|
logger.debug("Submit job for validation with id : {}", jobForValidation.getDatasourceId());
|
||||||
try {
|
try {
|
||||||
try {
|
emailUtils.sendSubmitJobForValidationEmail(SecurityContextHolder.getContext().getAuthentication(), jobForValidation);
|
||||||
emailUtils.sendSubmitJobForValidationEmail(SecurityContextHolder.getContext().getAuthentication(), jobForValidation);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.error("Error sending email ", e);
|
|
||||||
}
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
|
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
if (jobForValidation.getSelectedContentRules()!=null && jobForValidation.getSelectedContentRules().size() == 1 &&
|
if (jobForValidation.getSelectedContentRules()!=null && jobForValidation.getSelectedContentRules().size() == 1 &&
|
||||||
jobForValidation.getSelectedContentRules().contains(-1000)
|
jobForValidation.getSelectedContentRules().contains(-1000)
|
||||||
|| jobForValidation.getDesiredCompatibilityLevel().matches("openaire-cris_1.1")) {
|
|| jobForValidation.getDesiredCompatibilityLevel().equals("openaire-cris_1.1")) {
|
||||||
crisValidatorExecutor.submit(jobForValidation.getBaseUrl(), jobForValidation.getUserEmail());
|
crisValidatorExecutor.submit(jobForValidation.getBaseUrl(), jobForValidation.getUserEmail());
|
||||||
} else {
|
} else {
|
||||||
this.getValidationService().submitValidationJob(jobForValidation);
|
this.getValidationService().submitValidationJob(jobForValidation);
|
||||||
|
@ -151,7 +159,7 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
// this.getValidationService().submitValidationJob(jobForValidation);
|
// this.getValidationService().submitValidationJob(jobForValidation);
|
||||||
} catch (Exception e) { // FIXME: replaced exception with log
|
} catch (Exception e) { // FIXME: replaced exception with log
|
||||||
// throw new ValidatorServiceException(e);
|
// throw new ValidatorServiceException(e);
|
||||||
LOGGER.error(e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return jobForValidation;
|
return jobForValidation;
|
||||||
|
@ -160,7 +168,7 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Object> reSubmitJobForValidation(String email,
|
public ResponseEntity<Object> reSubmitJobForValidation(String email,
|
||||||
String jobId) throws JSONException, ValidatorServiceException {
|
String jobId) throws JSONException, ValidatorServiceException {
|
||||||
LOGGER.debug("Resubmit validation job with id : " + jobId);
|
logger.debug("Resubmit validation job with id : {}", jobId);
|
||||||
StoredJob job = monitorApi.getJobSummary(jobId, "all");
|
StoredJob job = monitorApi.getJobSummary(jobId, "all");
|
||||||
Set<Integer> contentRules = new HashSet<Integer>();
|
Set<Integer> contentRules = new HashSet<Integer>();
|
||||||
Set<Integer> usageRules = new HashSet<Integer>();
|
Set<Integer> usageRules = new HashSet<Integer>();
|
||||||
|
@ -195,20 +203,20 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RuleSet> getRuleSets(String mode) {
|
public List<RuleSet> getRuleSets(String mode) {
|
||||||
LOGGER.info("Getting rulesets for mode: " + mode);
|
logger.info("Getting ruleSets for mode: {}", mode);
|
||||||
return rulesetMap.get(mode);
|
return rulesetMap.get(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getSetsOfRepository(String url) {
|
public List<String> getSetsOfRepository(String url) {
|
||||||
LOGGER.debug("Getting sets of repository with url : " + url);
|
logger.debug("Getting sets of repository with url : {}", url);
|
||||||
|
|
||||||
List<String> sets = null;
|
List<String> sets = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sets = OaiTools.getSetsOfRepo(url);
|
sets = OaiTools.getSetsOfRepo(url);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Exception on getSetsOfRepository" , e);
|
logger.error("Exception on getSetsOfRepository", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sets;
|
return sets;
|
||||||
|
@ -216,18 +224,18 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean identifyRepo(String url) {
|
public boolean identifyRepo(String url) {
|
||||||
LOGGER.debug("Identify repository with url : " + url);
|
logger.debug("Identify repository with url : {}", url);
|
||||||
try {
|
try {
|
||||||
return OaiTools.identifyRepository(url);
|
return OaiTools.identifyRepository(url);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while identifying repository with url: " + url, e);
|
logger.error("Error while identifying repository with url: " + url, e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RuleSet getRuleSet(String acronym) {
|
public RuleSet getRuleSet(String acronym) {
|
||||||
LOGGER.debug("Getting ruleset with acronym : " + acronym);
|
logger.debug("Getting ruleset with acronym : {}", acronym);
|
||||||
RuleSet ruleSet = null;
|
RuleSet ruleSet = null;
|
||||||
try {
|
try {
|
||||||
for (List<RuleSet> ruleSets : this.rulesetMap.values()) {
|
for (List<RuleSet> ruleSets : this.rulesetMap.values()) {
|
||||||
|
@ -239,7 +247,7 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
}
|
}
|
||||||
return ruleSet;
|
return ruleSet;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error getting ruleset", e);
|
logger.error("Error getting ruleset", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,7 +286,7 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
@Override
|
@Override
|
||||||
public InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException {
|
public InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException {
|
||||||
try {
|
try {
|
||||||
LOGGER.debug("Getting interface information with url: " + baseUrl);
|
logger.debug("Getting interface information with url: {}", baseUrl);
|
||||||
InterfaceInformation interfaceInformation = new InterfaceInformation();
|
InterfaceInformation interfaceInformation = new InterfaceInformation();
|
||||||
interfaceInformation.setIdentified(this.identifyRepo(baseUrl));
|
interfaceInformation.setIdentified(this.identifyRepo(baseUrl));
|
||||||
if (interfaceInformation.isIdentified())
|
if (interfaceInformation.isIdentified())
|
||||||
|
@ -286,7 +294,7 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
|
|
||||||
return interfaceInformation;
|
return interfaceInformation;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error getting interface information with url: " + baseUrl, e);
|
logger.error("Error getting interface information with url: " + baseUrl, e);
|
||||||
throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.GENERAL_ERROR);
|
throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.GENERAL_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,4 +308,19 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
.collect(Collectors.toList()), limit);
|
.collect(Collectors.toList()), limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete(String repoId, String interfaceId, String jobId, String issuerEmail, boolean isUpdate, boolean isSuccess, int scoreUsage, int scoreContent) throws Exception {
|
||||||
|
emailUtils.sendUponJobCompletion(repoId,interfaceId,scoreUsage,scoreContent,isSuccess,isUpdate,issuerEmail, jobId);
|
||||||
|
InterfaceComplianceRequestId requestId = InterfaceComplianceRequestId.of(repoId, interfaceId);
|
||||||
|
Optional<InterfaceComplianceRequest> request = interfaceComplianceService.getById(requestId);
|
||||||
|
if (request.isPresent()) {
|
||||||
|
logger.info("Changing compatibility level. Request: {}", request);
|
||||||
|
|
||||||
|
if (scoreContent > 50) {
|
||||||
|
repositoryService.updateInterfaceCompliance(repoId, interfaceId, request.get().getDesiredCompatibilityLevel());
|
||||||
|
}
|
||||||
|
interfaceComplianceService.delete(requestId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,17 +3,21 @@ package eu.dnetlib.repo.manager.service.aai.registry;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import com.nimbusds.jose.util.StandardCharset;
|
||||||
import eu.dnetlib.repo.manager.domain.dto.Role;
|
import eu.dnetlib.repo.manager.domain.dto.Role;
|
||||||
import eu.dnetlib.repo.manager.domain.dto.User;
|
import eu.dnetlib.repo.manager.domain.dto.User;
|
||||||
import eu.dnetlib.repo.manager.service.aai.registry.utils.RegistryUtils;
|
import eu.dnetlib.repo.manager.service.aai.registry.utils.RegistryUtils;
|
||||||
import eu.dnetlib.repo.manager.utils.HttpUtils;
|
import eu.dnetlib.repo.manager.utils.HttpUtils;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -23,7 +27,7 @@ import java.util.Map;
|
||||||
@Service
|
@Service
|
||||||
public class RegistryCalls implements AaiRegistryService {
|
public class RegistryCalls implements AaiRegistryService {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(RegistryCalls.class);
|
private static final Logger logger = LoggerFactory.getLogger(RegistryCalls.class);
|
||||||
|
|
||||||
private final String coid;
|
private final String coid;
|
||||||
public final HttpUtils httpUtils;
|
public final HttpUtils httpUtils;
|
||||||
|
@ -98,11 +102,7 @@ public class RegistryCalls implements AaiRegistryService {
|
||||||
try {
|
try {
|
||||||
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||||
String sub = authentication.getUserInfo().getSub();
|
String sub = authentication.getUserInfo().getSub();
|
||||||
Map<String, String> params = new HashMap<>();
|
return getCoPersonIdByIdentifier(sub);
|
||||||
params.put("coid", coid);
|
|
||||||
params.put("search.identifier", sub);
|
|
||||||
JsonElement response = httpUtils.get("co_people.json", params);
|
|
||||||
return (response != null) ? response.getAsJsonObject().get("CoPeople").getAsJsonArray().get(0).getAsJsonObject().get("Id").getAsInt() : null;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Get User info: An error occurred ", e);
|
logger.error("Get User info: An error occurred ", e);
|
||||||
return null;
|
return null;
|
||||||
|
@ -122,7 +122,12 @@ public class RegistryCalls implements AaiRegistryService {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put("coid", coid);
|
params.put("coid", coid);
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
params.put("name", URLEncoder.encode(name).toLowerCase());
|
try {
|
||||||
|
params.put("name", URLEncoder.encode(name, StandardCharset.UTF_8.name()).toLowerCase());
|
||||||
|
} catch (UnsupportedEncodingException uee) {
|
||||||
|
logger.error(uee.getMessage());
|
||||||
|
return new JsonArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
JsonElement response = httpUtils.get("cous.json", params);
|
JsonElement response = httpUtils.get("cous.json", params);
|
||||||
return (response != null) ? response.getAsJsonObject().get("Cous").getAsJsonArray() : new JsonArray();
|
return (response != null) ? response.getAsJsonObject().get("Cous").getAsJsonArray() : new JsonArray();
|
||||||
|
@ -165,15 +170,18 @@ public class RegistryCalls implements AaiRegistryService {
|
||||||
@Override
|
@Override
|
||||||
public JsonArray getRolesWithStatus(Integer coPersonId, RoleStatus status) {
|
public JsonArray getRolesWithStatus(Integer coPersonId, RoleStatus status) {
|
||||||
JsonArray roles = getRoles(coPersonId);
|
JsonArray roles = getRoles(coPersonId);
|
||||||
if (status == null) {
|
if (roles == null) {
|
||||||
return roles;
|
roles = new JsonArray();
|
||||||
}
|
}
|
||||||
JsonArray activeRoles = new JsonArray();
|
JsonArray activeRoles = new JsonArray();
|
||||||
for (JsonElement role : roles) {
|
if (status != null) {
|
||||||
if (role.getAsJsonObject().get("Status").getAsString().equalsIgnoreCase(status.toString())) {
|
for (JsonElement role : roles) {
|
||||||
activeRoles.add(role);
|
if (role.getAsJsonObject().get("Status").getAsString().equalsIgnoreCase(status.toString())) {
|
||||||
|
activeRoles.add(role);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
assert activeRoles != null;
|
||||||
return activeRoles;
|
return activeRoles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,8 +304,11 @@ public class RegistryCalls implements AaiRegistryService {
|
||||||
JsonArray infos = getUserEmailByCouId(couId, false);
|
JsonArray infos = getUserEmailByCouId(couId, false);
|
||||||
|
|
||||||
infos.forEach(info -> {
|
infos.forEach(info -> {
|
||||||
|
JsonObject jsonInfo = info.getAsJsonObject();
|
||||||
|
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.setEmail(info.getAsJsonObject().get("email").getAsString());
|
user.setEmail(jsonInfo.get("email").getAsString());
|
||||||
|
// TODO: should add firstname and lastname and sub of user
|
||||||
|
|
||||||
users.add(user);
|
users.add(user);
|
||||||
});
|
});
|
||||||
|
@ -315,9 +326,10 @@ public class RegistryCalls implements AaiRegistryService {
|
||||||
JsonArray infos = (response != null) ? response.getAsJsonObject().get("Names").getAsJsonArray() : new JsonArray();
|
JsonArray infos = (response != null) ? response.getAsJsonObject().get("Names").getAsJsonArray() : new JsonArray();
|
||||||
JsonArray names = new JsonArray();
|
JsonArray names = new JsonArray();
|
||||||
infos.forEach(info -> {
|
infos.forEach(info -> {
|
||||||
|
JsonObject jsonInfo = info.getAsJsonObject();
|
||||||
JsonObject user = new JsonObject();
|
JsonObject user = new JsonObject();
|
||||||
user.addProperty("name", info.getAsJsonObject().get("Given").getAsString() + " " + info.getAsJsonObject().get("Family").getAsString());
|
user.addProperty("name", jsonInfo.get("Given").getAsString() + " " + jsonInfo.get("Family").getAsString());
|
||||||
user.addProperty("memberSince", info.getAsJsonObject().get("Created").getAsString());
|
user.addProperty("memberSince", jsonInfo.get("Created").getAsString());
|
||||||
names.add(user);
|
names.add(user);
|
||||||
});
|
});
|
||||||
return names;
|
return names;
|
||||||
|
@ -334,9 +346,10 @@ public class RegistryCalls implements AaiRegistryService {
|
||||||
JsonArray infos = (response != null) ? response.getAsJsonObject().get("Identifiers").getAsJsonArray() : new JsonArray();
|
JsonArray infos = (response != null) ? response.getAsJsonObject().get("Identifiers").getAsJsonArray() : new JsonArray();
|
||||||
JsonArray emails = new JsonArray();
|
JsonArray emails = new JsonArray();
|
||||||
infos.forEach(info -> {
|
infos.forEach(info -> {
|
||||||
|
JsonObject jsonInfo = info.getAsJsonObject();
|
||||||
JsonObject user = new JsonObject();
|
JsonObject user = new JsonObject();
|
||||||
user.addProperty("id", info.getAsJsonObject().get("Identifier").getAsString());
|
user.addProperty("id", jsonInfo.get("Identifier").getAsString());
|
||||||
user.addProperty("memberSince", info.getAsJsonObject().get("Created").getAsString());
|
user.addProperty("memberSince", jsonInfo.get("Created").getAsString());
|
||||||
emails.add(user);
|
emails.add(user);
|
||||||
});
|
});
|
||||||
return emails;
|
return emails;
|
||||||
|
@ -379,7 +392,11 @@ public class RegistryCalls implements AaiRegistryService {
|
||||||
params.put("copersonid", coPersonId.toString());
|
params.put("copersonid", coPersonId.toString());
|
||||||
JsonElement response = httpUtils.get("names.json", params);
|
JsonElement response = httpUtils.get("names.json", params);
|
||||||
JsonObject info = (response != null) ? response.getAsJsonObject().get("Names").getAsJsonArray().get(0).getAsJsonObject() : null;
|
JsonObject info = (response != null) ? response.getAsJsonObject().get("Names").getAsJsonArray().get(0).getAsJsonObject() : null;
|
||||||
return (info != null) ? info.getAsJsonObject().get("Given").getAsString() + " " + info.getAsJsonObject().get("Family").getAsString() : null;
|
if ( info != null ) {
|
||||||
|
JsonObject jsonInfo = info.getAsJsonObject();
|
||||||
|
return jsonInfo.get("Given").getAsString() + " " + jsonInfo.get("Family").getAsString();
|
||||||
|
} else
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -426,8 +443,9 @@ public class RegistryCalls implements AaiRegistryService {
|
||||||
int total = couIds.size();
|
int total = couIds.size();
|
||||||
for (JsonElement cou : cous) {
|
for (JsonElement cou : cous) {
|
||||||
if (count < total) {
|
if (count < total) {
|
||||||
if (idNameMap.containsKey(cou.getAsJsonObject().get("Id").getAsInt())) {
|
JsonObject jsonCou = cou.getAsJsonObject();
|
||||||
idNameMap.put(cou.getAsJsonObject().get("Id").getAsInt(), cou.getAsJsonObject().get("Name").getAsString());
|
if (idNameMap.containsKey(jsonCou.get("Id").getAsInt())) {
|
||||||
|
idNameMap.put(jsonCou.get("Id").getAsInt(), jsonCou.get("Name").getAsString());
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
|
||||||
|
|
||||||
import com.netflix.hystrix.HystrixCommand;
|
|
||||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
import org.springframework.web.util.UriComponents;
|
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class AggregatorsHystrixCommand extends HystrixCommand<String> {
|
|
||||||
|
|
||||||
RestTemplate restTemplate;
|
|
||||||
String baseAddress;
|
|
||||||
|
|
||||||
public AggregatorsHystrixCommand(String baseAddress, RestTemplate restTemplate) {
|
|
||||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
|
||||||
this.baseAddress = baseAddress;
|
|
||||||
this.restTemplate = restTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String run() throws Exception {
|
|
||||||
String url = baseAddress + "/resources" +
|
|
||||||
"?query= " +
|
|
||||||
" oaftype exact datasource and " +
|
|
||||||
" ( datasourcetypename exact Institutional Repository Aggregator " +
|
|
||||||
" or datasourcetypename exact Publication Repository Aggregator )";
|
|
||||||
|
|
||||||
UriComponents uriComponents = UriComponentsBuilder
|
|
||||||
.fromHttpUrl(url)
|
|
||||||
.queryParam("page", 0)
|
|
||||||
.queryParam("size", 0)
|
|
||||||
.queryParam("format", "json")
|
|
||||||
.build().encode();
|
|
||||||
|
|
||||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
|
||||||
Map metadata = (Map) ((Map) rs.getBody()).get("meta");
|
|
||||||
return String.valueOf(metadata.get("total"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getFallback() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
|
||||||
|
|
||||||
import com.netflix.hystrix.HystrixCommand;
|
|
||||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
import org.springframework.web.util.UriComponents;
|
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class DataRepositoriesHystrixCommand extends HystrixCommand<String> {
|
|
||||||
|
|
||||||
RestTemplate restTemplate ;
|
|
||||||
private String baseAddress;
|
|
||||||
|
|
||||||
public DataRepositoriesHystrixCommand(String baseAddress,RestTemplate restTemplate) {
|
|
||||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
|
||||||
this.baseAddress = baseAddress;
|
|
||||||
this.restTemplate = restTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String run() {
|
|
||||||
String url = baseAddress+"/resources" +
|
|
||||||
"?query= " +
|
|
||||||
" oaftype exact datasource and " +
|
|
||||||
" datasourcetypename exact Data Repository ";
|
|
||||||
|
|
||||||
UriComponents uriComponents = UriComponentsBuilder
|
|
||||||
.fromHttpUrl(url)
|
|
||||||
.queryParam("page",0)
|
|
||||||
.queryParam("size",0)
|
|
||||||
.queryParam("format","json")
|
|
||||||
.build().encode();
|
|
||||||
|
|
||||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET,null,Map.class);
|
|
||||||
Map metadata = (Map) ((Map)rs.getBody()).get("meta");
|
|
||||||
return String.valueOf(metadata.get("total"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getFallback() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
|
||||||
|
|
||||||
import com.netflix.hystrix.HystrixCommand;
|
|
||||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
import org.springframework.web.util.UriComponents;
|
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class DatasetsHystrixCommand extends HystrixCommand<String> {
|
|
||||||
|
|
||||||
RestTemplate restTemplate;
|
|
||||||
String baseAddress;
|
|
||||||
|
|
||||||
public DatasetsHystrixCommand(String baseAddress,RestTemplate restTemplate) {
|
|
||||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
|
||||||
this.restTemplate = restTemplate;
|
|
||||||
this.baseAddress = baseAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String run() throws Exception {
|
|
||||||
String url = baseAddress+"/datasets/count";
|
|
||||||
|
|
||||||
UriComponents uriComponents = UriComponentsBuilder
|
|
||||||
.fromHttpUrl(url)
|
|
||||||
.queryParam("page", 0)
|
|
||||||
.queryParam("size", 0)
|
|
||||||
.queryParam("format", "json")
|
|
||||||
.build().encode();
|
|
||||||
|
|
||||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
|
||||||
Map metadata = (Map) (rs.getBody());
|
|
||||||
return String.valueOf(metadata.get("total"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getFallback() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
|
||||||
|
|
||||||
import com.netflix.hystrix.HystrixCommand;
|
|
||||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
import org.springframework.web.util.UriComponents;
|
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class JournalHystrixCommand extends HystrixCommand<String> {
|
|
||||||
|
|
||||||
RestTemplate restTemplate;
|
|
||||||
private String baseAddress;
|
|
||||||
|
|
||||||
public JournalHystrixCommand(String baseAddress, RestTemplate restTemplate) {
|
|
||||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
|
||||||
this.baseAddress = baseAddress;
|
|
||||||
this.restTemplate = restTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String run() throws Exception {
|
|
||||||
String url = baseAddress+"/resources"+
|
|
||||||
"?query= " +
|
|
||||||
" oaftype exact datasource and " +
|
|
||||||
" datasourcetypename exact Journal";
|
|
||||||
|
|
||||||
UriComponents uriComponents = UriComponentsBuilder
|
|
||||||
.fromHttpUrl(url)
|
|
||||||
.queryParam("page", 0)
|
|
||||||
.queryParam("size", 0)
|
|
||||||
.queryParam("format", "json")
|
|
||||||
.build().encode();
|
|
||||||
|
|
||||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
|
||||||
Map metadata = (Map) ((Map) rs.getBody()).get("meta");
|
|
||||||
return String.valueOf(metadata.get("total"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getFallback() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
|
||||||
|
|
||||||
import com.netflix.hystrix.HystrixCommand;
|
|
||||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
import org.springframework.web.util.UriComponents;
|
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class LastYearUsageStatsHystrixCommand extends HystrixCommand<Map> {
|
|
||||||
|
|
||||||
RestTemplate restTemplate;
|
|
||||||
String usagestatsBaseAddress;
|
|
||||||
|
|
||||||
public LastYearUsageStatsHystrixCommand(String usagestatsBaseAddress,RestTemplate restTemplate) {
|
|
||||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
|
||||||
this.usagestatsBaseAddress = usagestatsBaseAddress;
|
|
||||||
this.restTemplate = restTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Map run() throws Exception {
|
|
||||||
UriComponents uriComponents = UriComponentsBuilder
|
|
||||||
.fromHttpUrl(usagestatsBaseAddress + "/totals")
|
|
||||||
.build().encode();
|
|
||||||
|
|
||||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET,null,Map.class);
|
|
||||||
|
|
||||||
List yearly_stats = (List) ((Map)rs.getBody()).get("yearly_stats");
|
|
||||||
Map lastYear = (Map) yearly_stats.get(yearly_stats.size()-1);
|
|
||||||
Integer downloads = (Integer) lastYear.get("downloads");
|
|
||||||
Integer views = (Integer) lastYear.get("views");
|
|
||||||
Integer year = (Integer) lastYear.get("year");
|
|
||||||
|
|
||||||
Map<String,Object> usagestats = new HashMap<>();
|
|
||||||
usagestats.put("number",String.valueOf(downloads+views));
|
|
||||||
usagestats.put("year",year);
|
|
||||||
|
|
||||||
return usagestats;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Map getFallback() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
|
||||||
|
|
||||||
import com.netflix.hystrix.HystrixCommand;
|
|
||||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
import org.springframework.web.util.UriComponents;
|
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class LiteratureHystrixCommand extends HystrixCommand<String> {
|
|
||||||
|
|
||||||
RestTemplate restTemplate;
|
|
||||||
private String baseAddress;
|
|
||||||
|
|
||||||
public LiteratureHystrixCommand(String baseAddress , RestTemplate restTemplate) {
|
|
||||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
|
||||||
this.baseAddress = baseAddress;
|
|
||||||
this.restTemplate = restTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String run() throws Exception {
|
|
||||||
String url = baseAddress+"/resources"+
|
|
||||||
"?query= " +
|
|
||||||
" oaftype exact datasource and " +
|
|
||||||
" ( datasourcetypename exact Institutional Repository " +
|
|
||||||
" or datasourcetypename exact Publication Repository )";
|
|
||||||
|
|
||||||
UriComponents uriComponents = UriComponentsBuilder
|
|
||||||
.fromHttpUrl(url)
|
|
||||||
.queryParam("page", 0)
|
|
||||||
.queryParam("size", 0)
|
|
||||||
.queryParam("format", "json")
|
|
||||||
.build().encode();
|
|
||||||
|
|
||||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
|
||||||
Map metadata = (Map) ((Map) rs.getBody()).get("meta");
|
|
||||||
return String.valueOf(metadata.get("total"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getFallback() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
|
||||||
|
|
||||||
import com.netflix.hystrix.HystrixCommand;
|
|
||||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
import org.springframework.web.util.UriComponents;
|
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class PublicationHystrixCommand extends HystrixCommand<String> {
|
|
||||||
|
|
||||||
RestTemplate restTemplate;
|
|
||||||
private String baseAddress;
|
|
||||||
|
|
||||||
public PublicationHystrixCommand(String baseAddress, RestTemplate restTemplate) {
|
|
||||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
|
||||||
this.baseAddress = baseAddress;
|
|
||||||
this.restTemplate = restTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String run() throws Exception {
|
|
||||||
String url = baseAddress + "/publications/count";
|
|
||||||
|
|
||||||
UriComponents uriComponents = UriComponentsBuilder
|
|
||||||
.fromHttpUrl(url)
|
|
||||||
.queryParam("page", 0)
|
|
||||||
.queryParam("size", 0)
|
|
||||||
.queryParam("format", "json")
|
|
||||||
.build().encode();
|
|
||||||
|
|
||||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
|
||||||
Map metadata = (Map) (rs.getBody());
|
|
||||||
return String.valueOf(metadata.get("total"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getFallback() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
|
||||||
|
|
||||||
import com.netflix.hystrix.HystrixCommand;
|
|
||||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
import org.springframework.web.util.UriComponents;
|
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class SoftwareHystrixCommand extends HystrixCommand<String> {
|
|
||||||
|
|
||||||
String baseAddress;
|
|
||||||
RestTemplate restTemplate;
|
|
||||||
|
|
||||||
public SoftwareHystrixCommand(String baseAddress, RestTemplate restTemplate) {
|
|
||||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
|
||||||
this.baseAddress = baseAddress;
|
|
||||||
this.restTemplate = restTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String run() {
|
|
||||||
String url = baseAddress + "/software/count";
|
|
||||||
|
|
||||||
UriComponents uriComponents = UriComponentsBuilder
|
|
||||||
.fromHttpUrl(url)
|
|
||||||
.queryParam("page", 0)
|
|
||||||
.queryParam("size", 0)
|
|
||||||
.queryParam("format", "json")
|
|
||||||
.build().encode();
|
|
||||||
|
|
||||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
|
|
||||||
Map metadata = (Map) (rs.getBody());
|
|
||||||
return String.valueOf(metadata.get("total"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getFallback() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.service.customHystrixCommands;
|
|
||||||
|
|
||||||
import com.netflix.hystrix.HystrixCommand;
|
|
||||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
import org.springframework.web.util.UriComponents;
|
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class UsageStatsTotalHystrixCommand extends HystrixCommand<Integer> {
|
|
||||||
|
|
||||||
RestTemplate restTemplate ;
|
|
||||||
String usagestatsEvents;
|
|
||||||
|
|
||||||
public UsageStatsTotalHystrixCommand(String usagestatsEvents,RestTemplate restTemplate) {
|
|
||||||
super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
|
|
||||||
this.usagestatsEvents = usagestatsEvents;
|
|
||||||
this.restTemplate = restTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Integer run() {
|
|
||||||
UriComponents uriComponents = UriComponentsBuilder
|
|
||||||
.fromHttpUrl(usagestatsEvents)
|
|
||||||
.build().encode();
|
|
||||||
|
|
||||||
ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET,null,Map.class);
|
|
||||||
Map metadata = (Map) ((Map)rs.getBody()).get("totals");
|
|
||||||
// String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
|
|
||||||
// JSONObject resultSet = new JSONObject(rs);
|
|
||||||
// JSONObject totals = resultSet.getJSONObject("totals");
|
|
||||||
return (Integer) metadata.get("events");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Integer getFallback() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.dnetlib.repo.manager.service.security;
|
package eu.dnetlib.repo.manager.service.security;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
|
@ -14,7 +15,7 @@ import java.util.stream.Collectors;
|
||||||
@Service("roleMappingService")
|
@Service("roleMappingService")
|
||||||
public class AaiRoleMappingService implements RoleMappingService {
|
public class AaiRoleMappingService implements RoleMappingService {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(AaiRoleMappingService.class);
|
private static final Logger logger = LoggerFactory.getLogger(AaiRoleMappingService.class);
|
||||||
|
|
||||||
@Value("${services.provide.aai.registry.production:true}")
|
@Value("${services.provide.aai.registry.production:true}")
|
||||||
private boolean production;
|
private boolean production;
|
||||||
|
|
|
@ -2,10 +2,13 @@ package eu.dnetlib.repo.manager.service.security;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import org.apache.log4j.Logger;
|
import com.nimbusds.jose.util.StandardCharset;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
@ -13,8 +16,8 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class AuthoritiesMapper {
|
public class AuthoritiesMapper {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(AuthoritiesMapper.class);
|
private static final Logger logger = LoggerFactory.getLogger(AuthoritiesMapper.class);
|
||||||
private static final String ENTITLEMENT_REGEX = "urn:geant:openaire[.]eu:group:([^:]*):?(.*)?:role=member#aai[.]openaire[.]eu";
|
private static final Pattern ENTITLEMENT_REGEX = Pattern.compile("urn:geant:openaire[.]eu:group:([^:]*):?(.*)?:role=member#aai[.]openaire[.]eu");
|
||||||
|
|
||||||
private AuthoritiesMapper() {
|
private AuthoritiesMapper() {
|
||||||
}
|
}
|
||||||
|
@ -25,22 +28,24 @@ public class AuthoritiesMapper {
|
||||||
return authorities;
|
return authorities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> entitlementRoles(JsonArray entitlements) {
|
public static List<String> entitlementRoles(JsonArray entitlements) throws UnsupportedEncodingException {
|
||||||
List<String> roles = new ArrayList<>();
|
List<String> roles = new ArrayList<>();
|
||||||
if (entitlements != null) {
|
if (entitlements != null) {
|
||||||
for (JsonElement obj : entitlements) {
|
for (JsonElement obj : entitlements) {
|
||||||
Matcher matcher = Pattern.compile(ENTITLEMENT_REGEX).matcher(obj.getAsString());
|
Matcher matcher = ENTITLEMENT_REGEX.matcher(obj.getAsString());
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (matcher.group(1) != null && matcher.group(1).length() > 0) {
|
String group1 = matcher.group(1);
|
||||||
sb.append(matcher.group(1));
|
if (group1 != null && group1.length() > 0) {
|
||||||
|
sb.append(group1);
|
||||||
}
|
}
|
||||||
if (matcher.group(2).length() > 0) {
|
String group2 = matcher.group(2);
|
||||||
|
if (group2.length() > 0) {
|
||||||
sb.append(":");
|
sb.append(":");
|
||||||
sb.append(matcher.group(2));
|
sb.append(group2);
|
||||||
}
|
}
|
||||||
String role = sb.toString().replace("+", " ");
|
String role = sb.toString().replace("+", " ");
|
||||||
roles.add(URLDecoder.decode(role));
|
roles.add(URLDecoder.decode(role, StandardCharset.UTF_8.name()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,18 +55,20 @@ public class AuthoritiesMapper {
|
||||||
private static void entityRoles(JsonArray entitlements, Set<GrantedAuthority> authorities) {
|
private static void entityRoles(JsonArray entitlements, Set<GrantedAuthority> authorities) {
|
||||||
if (entitlements != null) {
|
if (entitlements != null) {
|
||||||
for (JsonElement obj : entitlements) {
|
for (JsonElement obj : entitlements) {
|
||||||
Matcher matcher = Pattern.compile(ENTITLEMENT_REGEX).matcher(obj.getAsString());
|
Matcher matcher = ENTITLEMENT_REGEX.matcher(obj.getAsString());
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (matcher.group(1) != null && matcher.group(1).length() > 0) {
|
String group1 = matcher.group(1);
|
||||||
sb.append(matcher.group(1).replace("+-+", "_").replaceAll("[+.]", "_").toUpperCase());
|
if (group1 != null && group1.length() > 0) {
|
||||||
|
sb.append(group1.replace("+-+", "_").replaceAll("[+.]", "_").toUpperCase());
|
||||||
}
|
}
|
||||||
if (matcher.group(2).length() > 0) {
|
String group2 = matcher.group(2);
|
||||||
|
if (group2.length() > 0) {
|
||||||
sb.append("_");
|
sb.append("_");
|
||||||
if (matcher.group(2).equals("admins")) {
|
if (group2.equals("admins")) {
|
||||||
sb.append("MANAGER");
|
sb.append("MANAGER");
|
||||||
} else {
|
} else {
|
||||||
sb.append(matcher.group(2).toUpperCase());
|
sb.append(group2.toUpperCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
authorities.add(new SimpleGrantedAuthority(sb.toString()));
|
authorities.add(new SimpleGrantedAuthority(sb.toString()));
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package eu.dnetlib.repo.manager.service.security;
|
package eu.dnetlib.repo.manager.service.security;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
|
@ -9,8 +10,8 @@ import org.springframework.security.core.context.SecurityContext;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.security.oauth2.common.exceptions.UnauthorizedClientException;
|
import org.springframework.security.oauth2.common.exceptions.UnauthorizedClientException;
|
||||||
import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
|
import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
|
||||||
import org.springframework.session.Session;
|
|
||||||
import org.springframework.session.FindByIndexNameSessionRepository;
|
import org.springframework.session.FindByIndexNameSessionRepository;
|
||||||
|
import org.springframework.session.Session;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -21,25 +22,23 @@ import java.util.Map;
|
||||||
@Service
|
@Service
|
||||||
public class AuthoritiesUpdater extends HttpSessionSecurityContextRepository {
|
public class AuthoritiesUpdater extends HttpSessionSecurityContextRepository {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(AuthoritiesUpdater.class);
|
private static final Logger logger = LoggerFactory.getLogger(AuthoritiesUpdater.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
FindByIndexNameSessionRepository sessions;
|
FindByIndexNameSessionRepository sessions;
|
||||||
|
|
||||||
public void update(String id, Update update) {
|
public void update(String id, Update update) {
|
||||||
if (sessions != null) {
|
if (sessions != null) {
|
||||||
Map<String, Session> map = sessions.
|
Map map = sessions.findByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, id);
|
||||||
findByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, id);
|
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
logger.debug(map.values().toArray().length);
|
for ( Object sessionObject : map.values()) {
|
||||||
for (Session session : map.values()) {
|
Session session = (Session) sessionObject;
|
||||||
logger.debug(session.getId());
|
logger.debug(session.getId());
|
||||||
if (!session.isExpired()) {
|
if (!session.isExpired()) {
|
||||||
SecurityContext securityContext = session.getAttribute(SPRING_SECURITY_CONTEXT_KEY);
|
SecurityContext securityContext = session.getAttribute(SPRING_SECURITY_CONTEXT_KEY);
|
||||||
Authentication authentication = securityContext.getAuthentication();
|
Authentication authentication = securityContext.getAuthentication();
|
||||||
if (authentication instanceof OIDCAuthenticationToken) {
|
if (authentication instanceof OIDCAuthenticationToken) {
|
||||||
OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
|
OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
|
||||||
logger.debug(update.authorities(authOIDC.getAuthorities()));
|
|
||||||
securityContext.setAuthentication(new OIDCAuthenticationToken(authOIDC.getSub(), authOIDC.getIssuer(),
|
securityContext.setAuthentication(new OIDCAuthenticationToken(authOIDC.getSub(), authOIDC.getIssuer(),
|
||||||
authOIDC.getUserInfo(), update.authorities(authOIDC.getAuthorities()), authOIDC.getIdToken(),
|
authOIDC.getUserInfo(), update.authorities(authOIDC.getAuthorities()), authOIDC.getIdToken(),
|
||||||
authOIDC.getAccessTokenValue(), authOIDC.getRefreshTokenValue()));
|
authOIDC.getAccessTokenValue(), authOIDC.getRefreshTokenValue()));
|
||||||
|
@ -65,7 +64,7 @@ public class AuthoritiesUpdater extends HttpSessionSecurityContextRepository {
|
||||||
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||||
if (auth instanceof OIDCAuthenticationToken) {
|
if (auth instanceof OIDCAuthenticationToken) {
|
||||||
OIDCAuthenticationToken oidcAuth = (OIDCAuthenticationToken) auth;
|
OIDCAuthenticationToken oidcAuth = (OIDCAuthenticationToken) auth;
|
||||||
this.addRole(oidcAuth.getUserInfo().getEmail(), role);
|
this.addRole(oidcAuth.getUserInfo().getSub(), role);
|
||||||
} else {
|
} else {
|
||||||
throw new UnauthorizedClientException("User auth is not instance of OIDCAuthenticationToken");
|
throw new UnauthorizedClientException("User auth is not instance of OIDCAuthenticationToken");
|
||||||
}
|
}
|
||||||
|
@ -83,7 +82,7 @@ public class AuthoritiesUpdater extends HttpSessionSecurityContextRepository {
|
||||||
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||||
if (auth instanceof OIDCAuthenticationToken) {
|
if (auth instanceof OIDCAuthenticationToken) {
|
||||||
OIDCAuthenticationToken oidcAuth = (OIDCAuthenticationToken) auth;
|
OIDCAuthenticationToken oidcAuth = (OIDCAuthenticationToken) auth;
|
||||||
this.removeRole(oidcAuth.getUserInfo().getEmail(), role);
|
this.removeRole(oidcAuth.getUserInfo().getSub(), role);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,22 +38,22 @@ public interface AuthorizationService {
|
||||||
/**
|
/**
|
||||||
* Add a user as admin to a resource.
|
* Add a user as admin to a resource.
|
||||||
*
|
*
|
||||||
* @param id Resource id
|
* @param resourceId Resource id
|
||||||
* @param email User email
|
* @param email User email
|
||||||
* @return
|
* @return
|
||||||
* @throws ResourceNotFoundException
|
* @throws ResourceNotFoundException
|
||||||
*/
|
*/
|
||||||
boolean addAdmin(String id, String email) throws ResourceNotFoundException;
|
boolean addAdmin(String resourceId, String email) throws ResourceNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove user from resource admins.
|
* Remove user from resource admins.
|
||||||
*
|
*
|
||||||
* @param id Resource id
|
* @param resourceId Resource id
|
||||||
* @param email User email
|
* @param email User email
|
||||||
* @return
|
* @return
|
||||||
* @throws ResourceNotFoundException
|
* @throws ResourceNotFoundException
|
||||||
*/
|
*/
|
||||||
boolean removeAdmin(String id, String email) throws ResourceNotFoundException;
|
boolean removeAdmin(String resourceId, String email) throws ResourceNotFoundException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,6 +69,6 @@ public interface AuthorizationService {
|
||||||
* @param email
|
* @param email
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Collection<String> getUserRoles(String email);
|
Collection<String> getUserRolesByEmail(String email);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,25 @@
|
||||||
package eu.dnetlib.repo.manager.service.security;
|
package eu.dnetlib.repo.manager.service.security;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import eu.dnetlib.repo.manager.domain.dto.User;
|
import eu.dnetlib.repo.manager.domain.dto.User;
|
||||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||||
import eu.dnetlib.repo.manager.service.aai.registry.AaiRegistryService;
|
import eu.dnetlib.repo.manager.service.aai.registry.AaiRegistryService;
|
||||||
import org.apache.log4j.LogManager;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||||
import org.mitre.openid.connect.model.UserInfo;
|
import org.mitre.openid.connect.model.UserInfo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service("authorizationService")
|
@Service("authorizationService")
|
||||||
public class AuthorizationServiceImpl implements AuthorizationService {
|
public class AuthorizationServiceImpl implements AuthorizationService {
|
||||||
|
|
||||||
private static final Logger logger = LogManager.getLogger(AuthorizationServiceImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(AuthorizationServiceImpl.class);
|
||||||
|
|
||||||
public static final String SUPER_ADMINISTRATOR = "SUPER_ADMINISTRATOR";
|
public static final String SUPER_ADMINISTRATOR = "SUPER_ADMINISTRATOR";
|
||||||
public static final String CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR = "CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR";
|
public static final String CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR = "CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR";
|
||||||
|
@ -74,33 +70,26 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> getAdminsOfRepo(String repoId) {
|
public List<User> getAdminsOfRepo(String repoId) {
|
||||||
List<String> userList = new ArrayList<>();
|
|
||||||
|
|
||||||
// find couId by role name
|
// find couId by role name
|
||||||
String role = roleMappingService.getRoleIdByRepoId(repoId);
|
String role = roleMappingService.getRoleIdByRepoId(repoId);
|
||||||
Integer couId = aaiRegistryService.getCouId(role);
|
Integer couId = aaiRegistryService.getCouId(role);
|
||||||
if (couId != null) {
|
|
||||||
JsonArray users = aaiRegistryService.getUsersByCouId(couId);
|
|
||||||
for (JsonElement jsonElement : users) {
|
|
||||||
userList.add(jsonElement.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return aaiRegistryService.getUsers(couId);
|
return aaiRegistryService.getUsers(couId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAdmin(String id, String email) throws ResourceNotFoundException {
|
public boolean addAdmin(String resourceId, String email) throws ResourceNotFoundException {
|
||||||
Integer coPersonId = aaiRegistryService.getCoPersonIdByEmail(email);
|
Integer coPersonId = aaiRegistryService.getCoPersonIdByEmail(email);
|
||||||
if (coPersonId != null) {
|
if (coPersonId != null) {
|
||||||
String role = roleMappingService.getRoleIdByRepoId(id);
|
String role = roleMappingService.getRoleIdByRepoId(resourceId);
|
||||||
Integer couId = aaiRegistryService.getCouId(role);
|
Integer couId = aaiRegistryService.getCouId(role);
|
||||||
if (couId != null) {
|
if (couId != null) {
|
||||||
Integer roleId = aaiRegistryService.getRoleId(coPersonId, couId);
|
Integer roleId = aaiRegistryService.getRoleId(coPersonId, couId);
|
||||||
aaiRegistryService.assignMemberRole(coPersonId, couId, roleId);
|
aaiRegistryService.assignMemberRole(coPersonId, couId, roleId);
|
||||||
|
|
||||||
// Add role to user current authorities
|
// Add role to user current authorities
|
||||||
authoritiesUpdater.addRole(email, roleMappingService.convertRepoIdToAuthority(id));
|
authoritiesUpdater.addRole(email, roleMappingService.convertRepoIdToAuthority(resourceId));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -112,10 +101,10 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeAdmin(String id, String email) throws ResourceNotFoundException {
|
public boolean removeAdmin(String resourceId, String email) throws ResourceNotFoundException {
|
||||||
Integer coPersonId = aaiRegistryService.getCoPersonIdByEmail(email);
|
Integer coPersonId = aaiRegistryService.getCoPersonIdByEmail(email);
|
||||||
if (coPersonId != null) {
|
if (coPersonId != null) {
|
||||||
String role = roleMappingService.getRoleIdByRepoId(id);
|
String role = roleMappingService.getRoleIdByRepoId(resourceId);
|
||||||
Integer couId = aaiRegistryService.getCouId(role);
|
Integer couId = aaiRegistryService.getCouId(role);
|
||||||
Integer roleId = null;
|
Integer roleId = null;
|
||||||
if (couId != null) {
|
if (couId != null) {
|
||||||
|
@ -125,7 +114,7 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
||||||
aaiRegistryService.removeMemberRole(coPersonId, couId, roleId);
|
aaiRegistryService.removeMemberRole(coPersonId, couId, roleId);
|
||||||
|
|
||||||
// Remove role from user current authorities
|
// Remove role from user current authorities
|
||||||
authoritiesUpdater.removeRole(email, roleMappingService.convertRepoIdToAuthority(id));
|
authoritiesUpdater.removeRole(email, roleMappingService.convertRepoIdToAuthority(resourceId));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -140,14 +129,16 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
||||||
public Collection<String> getUserRoles() {
|
public Collection<String> getUserRoles() {
|
||||||
Collection<String> roles;
|
Collection<String> roles;
|
||||||
UserInfo userInfo = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo();
|
UserInfo userInfo = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo();
|
||||||
roles = getUserRoles(userInfo.getEmail());
|
roles = getUserRolesByEmail(userInfo.getEmail());
|
||||||
|
|
||||||
logger.debug(String.format("User Roles: %s", String.join(",", roles)));
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("User Roles: {}", String.join(",", roles));
|
||||||
|
}
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> getUserRoles(String email) {
|
public Collection<String> getUserRolesByEmail(String email) {
|
||||||
int coPersonId = aaiRegistryService.getCoPersonIdByEmail(email);
|
int coPersonId = aaiRegistryService.getCoPersonIdByEmail(email);
|
||||||
List<Integer> list = new ArrayList<>();
|
List<Integer> list = new ArrayList<>();
|
||||||
for (JsonElement element : aaiRegistryService.getRolesWithStatus(coPersonId, AaiRegistryService.RoleStatus.ACTIVE)) {
|
for (JsonElement element : aaiRegistryService.getRolesWithStatus(coPersonId, AaiRegistryService.RoleStatus.ACTIVE)) {
|
||||||
|
|
|
@ -4,29 +4,29 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.dnetlib.repo.manager.domain.*;
|
import eu.dnetlib.repo.manager.domain.*;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.text.ParseException;
|
import java.util.ArrayList;
|
||||||
import java.text.SimpleDateFormat;
|
import java.util.List;
|
||||||
import java.util.*;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class Converter {
|
public class Converter {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(Converter.class);
|
private static final Logger logger = LoggerFactory.getLogger(Converter.class);
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
|
|
||||||
public Converter() {
|
public Converter() {
|
||||||
objectMapper = new ObjectMapper();
|
objectMapper = new ObjectMapper()/*.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)*/;
|
||||||
}
|
}
|
||||||
public Repository toRepository(Object repositoryObject) {
|
public Repository toRepository(Object repositoryObject) {
|
||||||
|
|
||||||
|
@ -51,16 +51,7 @@ public class Converter {
|
||||||
return resultSet;
|
return resultSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RepositoryInterface> toRepositoryInterfaceList(JSONObject json) throws JSONException {
|
public List<RepositoryInterface> toRepositoryInterfaceList(List<ApiDetails> apiDetailsList) {
|
||||||
|
|
||||||
List<RepositoryInterface> resultSet = new ArrayList<>();
|
|
||||||
JSONArray rs = json.getJSONArray("api");
|
|
||||||
for (int i = 0; i < rs.length(); i++)
|
|
||||||
resultSet.add(toRepositoryInterface(rs.getJSONObject(i)));
|
|
||||||
return resultSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RepositoryInterface> toRepositoryInterfaceList(List<ApiDetails> apiDetailsList) throws JSONException {
|
|
||||||
|
|
||||||
List<RepositoryInterface> resultSet = new ArrayList<>();
|
List<RepositoryInterface> resultSet = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -85,27 +76,16 @@ public class Converter {
|
||||||
String line;
|
String line;
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
//InputStream in = Converter.class.getResourceAsStream("resources/eu/dnetlib/repo/manager/service/utils/"+filename);
|
InputStream in = Converter.class.getResourceAsStream("/eu/**/" + filename);
|
||||||
InputStream in = Converter.class.getClass().getResourceAsStream("/eu/**/" + filename);
|
BufferedReader br = new BufferedReader(new InputStreamReader(in)); // It may throw an NPE.
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
list.add(line.trim());
|
list.add(line.trim());
|
||||||
}
|
}
|
||||||
br.close();
|
br.close();
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
LOGGER.debug("Error opening file!");
|
logger.error("Error opening file!", e);
|
||||||
LOGGER.error(e);
|
|
||||||
}
|
}
|
||||||
return list;
|
return list; // It may be empty.
|
||||||
}
|
|
||||||
|
|
||||||
public List<AggregationDetails> toAggregationHistory(JSONArray aggregationInfo) throws JSONException {
|
|
||||||
List<AggregationDetails> aggregationDetailsList = new ArrayList<>();
|
|
||||||
|
|
||||||
for (int i = 0; i < aggregationInfo.length(); i++)
|
|
||||||
aggregationDetailsList.add(toAggregationDetails(aggregationInfo.getJSONObject(i)));
|
|
||||||
|
|
||||||
return aggregationDetailsList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Timezone> toTimezones(List<String> timezones) {
|
public List<Timezone> toTimezones(List<String> timezones) {
|
||||||
|
@ -128,29 +108,6 @@ public class Converter {
|
||||||
return value.equals("null") ? null : Boolean.valueOf(value);
|
return value.equals("null") ? null : Boolean.valueOf(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Date toDate(String date) {
|
|
||||||
|
|
||||||
if (Objects.equals(date, "null"))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
try {
|
|
||||||
return formatter.parse(date);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
LOGGER.error(e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString(Date date) {
|
|
||||||
|
|
||||||
if (Objects.equals(date, null))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
return formatter.format(date);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Double toDouble(String number) {
|
private Double toDouble(String number) {
|
||||||
if (Objects.equals(number, "null"))
|
if (Objects.equals(number, "null"))
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
@ -158,20 +115,5 @@ public class Converter {
|
||||||
return Double.valueOf(number);
|
return Double.valueOf(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AggregationDetails toAggregationDetails(JSONObject aggregationObject) throws JSONException {
|
|
||||||
|
|
||||||
AggregationDetails aggregationDetails = new AggregationDetails();
|
|
||||||
|
|
||||||
if (aggregationObject.has("collectionMode"))
|
|
||||||
aggregationDetails.setCollectionMode(aggregationObject.get("collectionMode").toString());
|
|
||||||
if (aggregationObject.has("indexedVersion"))
|
|
||||||
aggregationDetails.setIndexedVersion(Boolean.parseBoolean(aggregationObject.get("indexedVersion").toString()));
|
|
||||||
|
|
||||||
aggregationDetails.setAggregationStage(aggregationObject.get("aggregationStage").toString());
|
|
||||||
aggregationDetails.setDate(toDate(aggregationObject.get("date").toString()));
|
|
||||||
aggregationDetails.setNumberOfRecords(Integer.parseInt(aggregationObject.get("numberOfRecords").toString()));
|
|
||||||
|
|
||||||
return aggregationDetails;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.dnetlib.repo.manager.utils;
|
||||||
import eu.dnetlib.domain.functionality.validator.JobResultEntry;
|
import eu.dnetlib.domain.functionality.validator.JobResultEntry;
|
||||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||||
import org.eurocris.openaire.cris.validator.model.Job;
|
import org.eurocris.openaire.cris.validator.model.Job;
|
||||||
|
import org.eurocris.openaire.cris.validator.model.Rule;
|
||||||
import org.eurocris.openaire.cris.validator.model.RuleResults;
|
import org.eurocris.openaire.cris.validator.model.RuleResults;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
@ -20,14 +21,17 @@ public class CrisValidatorUtils {
|
||||||
StoredJob sj = new StoredJob();
|
StoredJob sj = new StoredJob();
|
||||||
sj.setId(job.getId().hashCode());
|
sj.setId(job.getId().hashCode());
|
||||||
sj.setValidationStatus(job.getStatus());
|
sj.setValidationStatus(job.getStatus());
|
||||||
if (job.getDateFinished() != null) {
|
|
||||||
sj.setEnded(DATE_FORMATTER.format(job.getDateFinished()));
|
Date dateFinished = job.getDateFinished();
|
||||||
sj.setDuration(DURATION_FORMATTER.format(new Date(job.getDateFinished().getTime() - job.getDateStarted().getTime())));
|
Date dateStarted = job.getDateStarted();
|
||||||
|
if ( dateFinished != null ) {
|
||||||
|
sj.setEnded(DATE_FORMATTER.format(dateFinished));
|
||||||
|
sj.setDuration(DURATION_FORMATTER.format(new Date(dateFinished.getTime() - dateStarted.getTime())));
|
||||||
} else {
|
} else {
|
||||||
sj.setEnded("-");
|
sj.setEnded("-");
|
||||||
sj.setDuration("-");
|
sj.setDuration("-");
|
||||||
}
|
}
|
||||||
sj.setStarted(DATE_FORMATTER.format(job.getDateStarted()));
|
sj.setStarted(DATE_FORMATTER.format(dateStarted));
|
||||||
|
|
||||||
sj.setUserEmail(job.getUser());
|
sj.setUserEmail(job.getUser());
|
||||||
sj.setCris(true);
|
sj.setCris(true);
|
||||||
|
@ -56,21 +60,24 @@ public class CrisValidatorUtils {
|
||||||
public static List<JobResultEntry> crisResultsToJobEntries(Job crisJob) {
|
public static List<JobResultEntry> crisResultsToJobEntries(Job crisJob) {
|
||||||
List<JobResultEntry> jobResultEntries = new ArrayList<>();
|
List<JobResultEntry> jobResultEntries = new ArrayList<>();
|
||||||
for (RuleResults ruleResults : crisJob.getRuleResults()) {
|
for (RuleResults ruleResults : crisJob.getRuleResults()) {
|
||||||
|
Rule rule = ruleResults.getRule();
|
||||||
JobResultEntry jobResultEntry = new JobResultEntry();
|
JobResultEntry jobResultEntry = new JobResultEntry();
|
||||||
jobResultEntry.setName(ruleResults.getRule().getName());
|
jobResultEntry.setName(rule.getName());
|
||||||
jobResultEntry.setRuleId(ruleResults.getRule().getId());
|
jobResultEntry.setRuleId(rule.getId());
|
||||||
jobResultEntry.setDescription(ruleResults.getRule().getDescription());
|
jobResultEntry.setDescription(rule.getDescription());
|
||||||
jobResultEntry.setMandatory(true);
|
jobResultEntry.setMandatory(true);
|
||||||
jobResultEntry.setWeight(Math.round(ruleResults.getRule().getWeight()));
|
jobResultEntry.setWeight(Math.round(rule.getWeight()));
|
||||||
jobResultEntry.setType(ruleResults.getRule().getType());
|
jobResultEntry.setType(rule.getType());
|
||||||
jobResultEntry.setHasErrors(false);
|
jobResultEntry.setHasErrors(false);
|
||||||
if (ruleResults.getCount() == 0) {
|
long countRuleResults = ruleResults.getCount();
|
||||||
|
if (countRuleResults == 0) {
|
||||||
jobResultEntry.setSuccesses("-");
|
jobResultEntry.setSuccesses("-");
|
||||||
} else {
|
} else {
|
||||||
jobResultEntry.setSuccesses(ruleResults.getCount() - ruleResults.getFailed() + "/" + ruleResults.getCount());
|
jobResultEntry.setSuccesses(countRuleResults - ruleResults.getFailed() + "/" + countRuleResults);
|
||||||
}
|
}
|
||||||
if (ruleResults.getErrorMessages() != null && !ruleResults.getErrorMessages().isEmpty()) {
|
List<String> errorMessages = ruleResults.getErrorMessages();
|
||||||
jobResultEntry.setErrors(ruleResults.getErrorMessages());
|
if (errorMessages != null && !errorMessages.isEmpty()) {
|
||||||
|
jobResultEntry.setErrors(errorMessages);
|
||||||
jobResultEntry.setHasErrors(true);
|
jobResultEntry.setHasErrors(true);
|
||||||
}
|
}
|
||||||
jobResultEntries.add(jobResultEntry);
|
jobResultEntries.add(jobResultEntry);
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package eu.dnetlib.repo.manager.utils;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class DateUtils {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(DateUtils.class);
|
||||||
|
|
||||||
|
public static Date toDate(String date) {
|
||||||
|
|
||||||
|
if (Objects.equals(date, "null"))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
try {
|
||||||
|
return formatter.parse(date);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toString(Date date) {
|
||||||
|
|
||||||
|
if (Objects.equals(date, null))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
return formatter.format(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getYear(String date) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(Objects.requireNonNull(toDate(date)));
|
||||||
|
return String.valueOf(calendar.get(Calendar.YEAR));
|
||||||
|
}
|
||||||
|
|
||||||
|
private DateUtils() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,19 +4,20 @@ import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class HttpUtils {
|
public class HttpUtils {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(HttpUtils.class);
|
private static final Logger logger = LoggerFactory.getLogger(HttpUtils.class);
|
||||||
|
|
||||||
@Value("${services.provide.aai.registry.url}")
|
@Value("${services.provide.aai.registry.url}")
|
||||||
private String registryUrl;
|
private String registryUrl;
|
||||||
|
@ -78,20 +79,24 @@ public class HttpUtils {
|
||||||
private HttpHeaders createHeaders(String username, String password) {
|
private HttpHeaders createHeaders(String username, String password) {
|
||||||
return new HttpHeaders() {{
|
return new HttpHeaders() {{
|
||||||
String auth = username + ":" + password;
|
String auth = username + ":" + password;
|
||||||
byte[] encodedAuth = Base64.encodeBase64(
|
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.US_ASCII));
|
||||||
auth.getBytes(Charset.forName("US-ASCII")));
|
|
||||||
String authHeader = "Basic " + new String(encodedAuth);
|
String authHeader = "Basic " + new String(encodedAuth);
|
||||||
set("Authorization", authHeader);
|
set("Authorization", authHeader);
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
private JsonElement getResponseEntityAsJsonElement(ResponseEntity<String> responseEntity) {
|
private JsonElement getResponseEntityAsJsonElement(ResponseEntity<String> responseEntity) {
|
||||||
if (responseEntity != null && responseEntity.getBody() != null) {
|
|
||||||
logger.debug(responseEntity.getBody());
|
if ( responseEntity == null )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
String responseBody = responseEntity.getBody();
|
||||||
|
if ( responseBody != null ) {
|
||||||
|
logger.debug(responseBody);
|
||||||
try {
|
try {
|
||||||
return new JsonParser().parse(responseEntity.getBody());
|
return new JsonParser().parse(responseBody);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("Could not parse response body", e);
|
logger.warn("Could not parse response body", e); // Will return null.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package eu.dnetlib.repo.manager.utils;
|
package eu.dnetlib.repo.manager.utils;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.dom4j.io.DOMWriter;
|
import org.dom4j.io.DOMWriter;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import se.kb.oai.pmh.*;
|
import se.kb.oai.pmh.*;
|
||||||
|
|
||||||
|
@ -24,16 +25,15 @@ public class OaiTools {
|
||||||
disableSslVerification();
|
disableSslVerification();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Logger LOGGER = Logger.getLogger(OaiTools.class);
|
private static Logger logger = LoggerFactory.getLogger(OaiTools.class);
|
||||||
|
|
||||||
public static List<String> getSetsOfRepo(String baseUrl) throws Exception {
|
public static List<String> getSetsOfRepo(String baseUrl) throws Exception {
|
||||||
try {
|
try {
|
||||||
LOGGER.debug("Getting sets of repository " + baseUrl);
|
logger.debug("Getting sets of repository: {}", baseUrl);
|
||||||
OaiPmhServer harvester = new OaiPmhServer(baseUrl);
|
OaiPmhServer harvester = new OaiPmhServer(baseUrl);
|
||||||
SetsList setList = harvester.listSets();
|
SetsList setList = harvester.listSets();
|
||||||
ResumptionToken token = setList.getResumptionToken();
|
ResumptionToken token = setList.getResumptionToken();
|
||||||
List<Set> sets = new ArrayList<Set>();
|
List<Set> sets = new ArrayList<>(setList.asList());
|
||||||
sets.addAll(setList.asList());
|
|
||||||
while (token != null) {
|
while (token != null) {
|
||||||
setList = harvester.listSets(token);
|
setList = harvester.listSets(token);
|
||||||
token = setList.getResumptionToken();
|
token = setList.getResumptionToken();
|
||||||
|
@ -49,14 +49,14 @@ public class OaiTools {
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error getting sets of repository " + baseUrl, e);
|
logger.error("Error getting sets of repository " + baseUrl, e);
|
||||||
return new ArrayList<String>();
|
return new ArrayList<String>();
|
||||||
//throw e;
|
//throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean identifyRepository(String baseUrl) throws Exception {
|
public static boolean identifyRepository(String baseUrl) throws Exception {
|
||||||
LOGGER.debug("sending identify request to repo " + baseUrl);
|
logger.debug("sending identify request to repo: {}", baseUrl);
|
||||||
|
|
||||||
OaiPmhServer harvester = new OaiPmhServer(baseUrl);
|
OaiPmhServer harvester = new OaiPmhServer(baseUrl);
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class OaiTools {
|
||||||
|
|
||||||
return verifyIdentify(d);
|
return verifyIdentify(d);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.debug("Error verifying identify response", e);
|
logger.debug("Error verifying identify response", e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ public class OaiTools {
|
||||||
private static void disableSslVerification() {
|
private static void disableSslVerification() {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LOGGER.debug("disabling ssl verification");
|
logger.debug("disabling ssl verification");
|
||||||
// Create a trust manager that does not validate certificate chains
|
// Create a trust manager that does not validate certificate chains
|
||||||
TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
|
TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
|
||||||
public X509Certificate[] getAcceptedIssuers() {
|
public X509Certificate[] getAcceptedIssuers() {
|
||||||
|
@ -140,9 +140,9 @@ public class OaiTools {
|
||||||
// Install the all-trusting host verifier
|
// Install the all-trusting host verifier
|
||||||
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
|
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
LOGGER.error("disabling ssl verification", e);
|
logger.error("disabling ssl verification", e);
|
||||||
} catch (KeyManagementException e) {
|
} catch (KeyManagementException e) {
|
||||||
LOGGER.error("error while disabling ssl verification", e);
|
logger.error("error while disabling ssl verification", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.dnetlib.repo.manager.controllers;
|
package eu.dnetlib.repo.manager.utils;
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.exception.EndPointException;
|
import eu.dnetlib.repo.manager.exception.EndPointException;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
@ -16,19 +16,17 @@ public class RestTemplateResponseErrorHandler implements ResponseErrorHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasError(ClientHttpResponse httpResponse) throws IOException {
|
public boolean hasError(ClientHttpResponse httpResponse) throws IOException {
|
||||||
return (httpResponse.getStatusCode().series() == CLIENT_ERROR
|
HttpStatus.Series seriesError = httpResponse.getStatusCode().series();
|
||||||
|| httpResponse.getStatusCode().series() == SERVER_ERROR);
|
return ( (seriesError == CLIENT_ERROR) || (seriesError == SERVER_ERROR) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleError(ClientHttpResponse httpResponse) throws IOException {
|
public void handleError(ClientHttpResponse httpResponse) throws IOException {
|
||||||
|
|
||||||
if (httpResponse.getStatusCode().series() == HttpStatus.Series.SERVER_ERROR) {
|
HttpStatus statusCode = httpResponse.getStatusCode();
|
||||||
|
if ( statusCode == HttpStatus.NOT_FOUND )
|
||||||
|
throw new IOException();
|
||||||
|
else if (statusCode.series() == SERVER_ERROR)
|
||||||
throw new EndPointException();
|
throw new EndPointException();
|
||||||
} else if (httpResponse.getStatusCode().series() == HttpStatus.Series.CLIENT_ERROR) {
|
|
||||||
if (httpResponse.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
||||||
throw new IOException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
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 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
|
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:annotation-config/>
|
||||||
|
|
|
@ -1,14 +1,30 @@
|
||||||
|
springdoc.swagger-ui:
|
||||||
|
disable-swagger-default-url: true
|
||||||
|
version: 3
|
||||||
|
|
||||||
|
spring:
|
||||||
|
jpa:
|
||||||
|
hibernate:
|
||||||
|
ddl-auto: update
|
||||||
|
|
||||||
|
datasource:
|
||||||
|
url: ${services.provide.db.url}
|
||||||
|
username: ${services.provide.db.username}
|
||||||
|
password: ${services.provide.db.password}
|
||||||
|
driverClassName: ${services.provide.db.driverClassName}
|
||||||
|
|
||||||
services:
|
services:
|
||||||
provide:
|
provide:
|
||||||
|
dev-machine: 88.197.53.71
|
||||||
aai:
|
aai:
|
||||||
baseURL: https://aai.openaire.eu
|
baseURL: https://aai.openaire.eu
|
||||||
oidc:
|
oidc:
|
||||||
domain: .openaire.eu
|
domain: .openaire.eu
|
||||||
id: XX
|
id: XX
|
||||||
issuer: ${services.provide.aai.baseURL}/oidc/
|
issuer: ${services.provide.aai.baseURL}/oidc/
|
||||||
redirectURL: http://88.197.53.69/api/openid_connect_login
|
redirectURL: http://localhost:${server.port}${server.servlet.context-path}/openid_connect_login
|
||||||
secret: XX
|
secret: XX
|
||||||
webURL: http://88.197.53.69/join
|
webURL: http://localhost:4200/join
|
||||||
registry:
|
registry:
|
||||||
coid: XX
|
coid: XX
|
||||||
password: XX
|
password: XX
|
||||||
|
@ -17,21 +33,21 @@ services:
|
||||||
username: provide_openaire
|
username: provide_openaire
|
||||||
adminEmail: XX
|
adminEmail: XX
|
||||||
analyticsURL: https://analytics.openaire.eu/addsite.php?
|
analyticsURL: https://analytics.openaire.eu/addsite.php?
|
||||||
baseUrl: https://beta.provide.openaire.eu/
|
baseUrl: https://dev-openaire.d4science.org/openaire
|
||||||
broker:
|
broker:
|
||||||
api: api/
|
api: api/
|
||||||
openaire: openaireBroker
|
openaire: openaireBroker
|
||||||
port: 8080
|
port: 8080
|
||||||
url: https://broker1-dev-dnet.d4science.org
|
url: https://broker1-dev-dnet.d4science.org
|
||||||
clients:
|
clients:
|
||||||
dsm: https://beta.services.openaire.eu/openaire
|
dsm: https://dev-openaire.d4science.org/openaire
|
||||||
search: https://beta.services.openaire.eu/search/v2/api
|
search: https://beta.services.openaire.eu/search/v2/api
|
||||||
usageEvents: http://beta.lbs.openaire.eu:8080/ajax/summary
|
usageEvents: http://beta.lbs.openaire.eu:8080/ajax/summary
|
||||||
usagestats: https://services.openaire.eu/usagestats
|
usagestats: https://services.openaire.eu/usagestats
|
||||||
db:
|
db:
|
||||||
driverClassName: org.postgresql.Driver
|
driverClassName: org.postgresql.Driver
|
||||||
password: dnetPwd
|
password: dnetPwd
|
||||||
url: jdbc:postgresql://localhost:5432/repomanager
|
url: jdbc:postgresql://${services.provide.dev-machine}:5432/repomanager
|
||||||
username: dnet
|
username: dnet
|
||||||
iSLookUpService:
|
iSLookUpService:
|
||||||
url: https://dev-openaire.d4science.org:443/is/services/isLookUp
|
url: https://dev-openaire.d4science.org:443/is/services/isLookUp
|
||||||
|
@ -46,8 +62,8 @@ services:
|
||||||
replyTo: XX
|
replyTo: XX
|
||||||
username: XX
|
username: XX
|
||||||
redis:
|
redis:
|
||||||
host: localhost
|
host: vereniki.athenarc.gr
|
||||||
password: 2106875370
|
password: XX
|
||||||
port: 6379
|
port: 6379
|
||||||
topic_types:
|
topic_types:
|
||||||
url: https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:topic_types.json
|
url: https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:topic_types.json
|
||||||
|
@ -60,4 +76,4 @@ services:
|
||||||
results:
|
results:
|
||||||
url: https://beta.provide.openaire.eu/compatibility/browseHistory/
|
url: https://beta.provide.openaire.eu/compatibility/browseHistory/
|
||||||
validatorService:
|
validatorService:
|
||||||
url: http://88.197.53.69:8080/uoa-validator-service/services/validatorWebService
|
url: http://${services.provide.dev-machine}:8080/uoa-validator-service/services/validatorWebService
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
</Console>
|
</Console>
|
||||||
</Appenders>
|
</Appenders>
|
||||||
<Loggers>
|
<Loggers>
|
||||||
|
<Root level="info">
|
||||||
|
<AppenderRef ref="LogToConsole"/>
|
||||||
|
</Root>
|
||||||
<Logger name="org.springframework.boot" level="error" additivity="false">
|
<Logger name="org.springframework.boot" level="error" additivity="false">
|
||||||
<AppenderRef ref="LogToConsole"/>
|
<AppenderRef ref="LogToConsole"/>
|
||||||
</Logger>
|
</Logger>
|
||||||
<Root level="error">
|
|
||||||
<AppenderRef ref="LogToConsole"/>
|
|
||||||
</Root>
|
|
||||||
</Loggers>
|
</Loggers>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
|
||||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||||
|
|
||||||
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
||||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
|
|
||||||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
|
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
|
||||||
|
|
||||||
<import resource="classpath*:/application-context.xml"/>
|
<import resource="classpath*:/application-context.xml"/>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package metrics;
|
package eu.dnetlib.repo.manager.integration.metrics;
|
||||||
|
|
||||||
import eu.dnetlib.repo.manager.controllers.PrometheusController;
|
import eu.dnetlib.repo.manager.controllers.PrometheusController;
|
||||||
import eu.dnetlib.repo.manager.service.PiWikService;
|
import eu.dnetlib.repo.manager.service.PiWikService;
|
|
@ -0,0 +1,58 @@
|
||||||
|
package eu.dnetlib.repo.manager.integration.service;
|
||||||
|
|
||||||
|
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequest;
|
||||||
|
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequestId;
|
||||||
|
import eu.dnetlib.repo.manager.repository.InterfaceComplianceRequestsRepository;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
|
||||||
|
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@DataJpaTest
|
||||||
|
//@AutoConfigureTestDatabase
|
||||||
|
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
|
||||||
|
//@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||||
|
class InterfaceComplianceRequestTests {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InterfaceComplianceRequestsRepository repository;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getRequestById() {
|
||||||
|
InterfaceComplianceRequest request = createRequest("3");
|
||||||
|
repository.save(request);
|
||||||
|
long total = repository.count();
|
||||||
|
Assert.assertEquals(1, total);
|
||||||
|
InterfaceComplianceRequest r = repository.findById(createRequestId()).orElse(null);
|
||||||
|
Assert.assertNotNull(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
public void deleteRequestAfterTests() {
|
||||||
|
repository.deleteById(createRequestId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private InterfaceComplianceRequestId createRequestId() {
|
||||||
|
InterfaceComplianceRequestId id = new InterfaceComplianceRequestId();
|
||||||
|
id.setRepositoryId("repository");
|
||||||
|
id.setInterfaceId("interface");
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
private InterfaceComplianceRequest createRequest(String compatibilityLevel) {
|
||||||
|
InterfaceComplianceRequest request = new InterfaceComplianceRequest();
|
||||||
|
InterfaceComplianceRequestId id = createRequestId();
|
||||||
|
request.setRepositoryId(id.getRepositoryId());
|
||||||
|
request.setInterfaceId(id.getInterfaceId());
|
||||||
|
request.setDesiredCompatibilityLevel(compatibilityLevel);
|
||||||
|
request.setSubmissionDate(new Date());
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package eu.dnetlib.repo.manager.unit;
|
||||||
|
|
||||||
|
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequest;
|
||||||
|
import eu.dnetlib.repo.manager.domain.dto.InterfaceComplianceRequestDTO;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
|
||||||
|
@SpringBootTest(classes = InterfaceComplianceRequest.class)
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
class InterfaceComplianceRequestTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void interfaceComplianceRequest_contains_date_test() {
|
||||||
|
InterfaceComplianceRequest request = new InterfaceComplianceRequest();
|
||||||
|
Assert.assertNotNull(request.getSubmissionDate());
|
||||||
|
|
||||||
|
InterfaceComplianceRequestDTO dto = new InterfaceComplianceRequestDTO();
|
||||||
|
Assert.assertNull(dto.getSubmissionDate());
|
||||||
|
|
||||||
|
request = InterfaceComplianceRequest.from(dto);
|
||||||
|
Assert.assertNotNull(request.getSubmissionDate());
|
||||||
|
}
|
||||||
|
}
|
|
@ -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" xmlns:tx="http://www.springframework.org/schema/tx"
|
|
||||||
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 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.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>
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
url: jdbc:h2:mem:test
|
||||||
|
driverClassName: org.h2.Driver
|
||||||
|
h2:
|
||||||
|
console:
|
||||||
|
enabled: true
|
||||||
|
jpa:
|
||||||
|
show-sql: true
|
||||||
|
hibernate:
|
||||||
|
ddl-auto: update
|
||||||
|
main:
|
||||||
|
banner-mode: console
|
|
@ -1,70 +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:tx="http://www.springframework.org/schema/tx"
|
|
||||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
||||||
|
|
||||||
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
|
||||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
|
|
||||||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
|
|
||||||
|
|
||||||
<import resource="classpath*:/application-context.xml"/>
|
|
||||||
|
|
||||||
<import resource="classpath*:/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.xml"/>
|
|
||||||
<import resource="classpath*:/eu/dnetlib/clients/ws/springContext-locatorFactory.xml"/>
|
|
||||||
<import resource="classpath*:/gr/uoa/di/driver/util/springContext-locators.xml"/>
|
|
||||||
<import resource="classpath*:/gr/uoa/di/driver/app/springContext-lookupFactory.xml"/>
|
|
||||||
<import resource="classpath*:/gr/uoa/di/driver/app/springContext-lookupClients.xml"/>
|
|
||||||
<import resource="classpath*:/eu/dnetlib/enabling/hcm/springContext-hcmService.xml"/>
|
|
||||||
<import resource="classpath*:/gr/uoa/di/driver/app/springContext-commons.xml"/>
|
|
||||||
|
|
||||||
<!--<import resource="classpath*:/gr/uoa/di/driver/app/springContext-registrator.xml"/>-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<bean id="maillib" class="eu.dnetlib.utils.MailLibrary" init-method="init">
|
|
||||||
<property name="mailhost" value="${services.validator.mail.host}"/>
|
|
||||||
<property name="smtpPort" value="${services.validator.mail.port}"/>
|
|
||||||
<property name="authenticate" value="${services.validator.mail.authenticate}"/>
|
|
||||||
<property name="username" value="${services.validator.mail.username}"/>
|
|
||||||
<property name="password" value="${services.validator.mail.password}"/>
|
|
||||||
<property name="from" value="${services.validator.mail.fromAddress}"/>
|
|
||||||
<property name="replyTo" value="${services.validator.mail.replyToAddress}"/>
|
|
||||||
<property name="mode" value="${services.validator.mail.mode}"/>
|
|
||||||
<property name="debug" value="${services.validator.mail.debug}"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<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-new.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>
|
|
Loading…
Reference in New Issue