removed trunk from cris branch
This commit is contained in:
parent
d5ce42fa43
commit
c240fc1030
|
@ -1,11 +0,0 @@
|
|||
FROM tomcat:7.0.90-jre8
|
||||
MAINTAINER "pkanakakis@di.uoa.gr"
|
||||
RUN ["rm", "-fr", "/usr/local/tomcat/webapps/ROOT"]
|
||||
COPY ./target/uoa-repository-manager-service.war /usr/local/tomcat/webapps/uoa-repository-manager-service.war
|
||||
#COPY src/main/resources/dnet-override-new.properties /usr/local/tomcat/lib/dnet-override.properties
|
||||
COPY src/main/resources/application.properties /usr/local/tomcat/lib/dnet-override.properties
|
||||
#COPY src/main/resources/application.properties /usr/local/tomcat/lib/application.properties
|
||||
#COPY src/main/resources/email-texts.properties /usr/local/tomcat/lib/email-texts.properties
|
||||
VOLUME /var/log/uoa-repository-manager-service:/var/log/uoa-repository-manager-service/
|
||||
CMD ["catalina.sh", "run"]
|
||||
|
335
trunk/pom.xml
335
trunk/pom.xml
|
@ -1,335 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>dnet45-parent</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>uoa-repository-manager-service</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
|
||||
|
||||
<dependencies>
|
||||
|
||||
<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>(1.2, 1.5]</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>dnet-runtime</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0)</version>
|
||||
<exclusions>
|
||||
<exclusion> <!-- declare the exclusion here -->
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-javamail_1.4_spec</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>uoa-utils</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0)</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>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>dnet-openaire-usage-stats-sushilite</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>cglib</groupId>
|
||||
<artifactId>cglib-nodep</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>uoa-commons</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>uoa-clients</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>uoa-hcm</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>se.kb</groupId>
|
||||
<artifactId>oai4j</artifactId>
|
||||
<version>[0.6b1,)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xalan</groupId>
|
||||
<artifactId>xalan</artifactId>
|
||||
<version>2.7.2</version>
|
||||
</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.5.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.5.1</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>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-client</artifactId>
|
||||
<version>1.19.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.aksw.gson</groupId>
|
||||
<artifactId>gson-utils-core</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20080701</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<version>1.6.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/postgresql/postgresql -->
|
||||
<dependency>
|
||||
<groupId>postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>9.1-901.jdbc3</version>
|
||||
</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>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mitre</groupId>
|
||||
<artifactId>openid-connect-client</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-data-redis</artifactId>
|
||||
<version>1.3.1.RELEASE</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>2.9.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.thetransactioncompany</groupId>
|
||||
<artifactId>cors-filter</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-hystrix</artifactId>
|
||||
<version>1.1.5.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
|
||||
<dependency>
|
||||
<groupId>javax.xml.ws</groupId>
|
||||
<artifactId>jaxws-api</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/javax.jws/javax.jws-api -->
|
||||
<dependency>
|
||||
<groupId>javax.jws</groupId>
|
||||
<artifactId>javax.jws-api</artifactId>
|
||||
<version>1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-core -->
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
<version>1.1-rev-1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>cz.habarta.typescript-generator</groupId>
|
||||
<artifactId>typescript-generator-maven-plugin</artifactId>
|
||||
<version>2.1.406</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>java to typeScript</id>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<jsonLibrary>jackson2</jsonLibrary>
|
||||
<outputFileType>implementationFile</outputFileType>
|
||||
<mapClasses>asClasses</mapClasses>
|
||||
<classPatterns>
|
||||
<pattern>eu.dnetlib.domain.functionality.validator.*</pattern>
|
||||
</classPatterns>
|
||||
<outputFile>target/operation.ts</outputFile>
|
||||
<outputKind>module</outputKind>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>uoa-repository-manager-service</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
|
@ -1,55 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* CascadingPropertyLoader loads a number of property files and mergers them together, so that the last properties
|
||||
* override the previous. It also supports property expansion like:
|
||||
*
|
||||
* <code>
|
||||
* something = 1
|
||||
* somethingelse = 2
|
||||
* test = ${something}/${somethingelse}
|
||||
* </code>
|
||||
*
|
||||
* <p>
|
||||
* And if you override something to XX, then test will become XX/2
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author marko
|
||||
*
|
||||
*/
|
||||
public class CascadingPropertyLoader extends PropertyPlaceholderConfigurer implements InitializingBean {
|
||||
|
||||
private Properties properties;
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
this.properties = mergeProperties();
|
||||
|
||||
// Convert the merged properties, if necessary.
|
||||
convertProperties(this.properties);
|
||||
|
||||
logger.debug("Properties: " + properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processProperties(final ConfigurableListableBeanFactory beanFactoryToProcess, final Properties props) throws BeansException {
|
||||
super.processProperties(beanFactoryToProcess, props);
|
||||
}
|
||||
|
||||
public Properties getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(final Properties properties) {
|
||||
super.setProperties(properties);
|
||||
|
||||
this.properties = properties;
|
||||
}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
|
||||
import org.springframework.context.annotation.*;
|
||||
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.web.http.CookieSerializer;
|
||||
import org.springframework.session.web.http.DefaultCookieSerializer;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@Configuration
|
||||
@EnableRedisHttpSession
|
||||
@EnableAspectJAutoProxy
|
||||
@EnableCircuitBreaker
|
||||
@PropertySource(value = {"classpath:application.properties"} )
|
||||
@ComponentScan(basePackages = "eu.dnetlib.repo.manager.*")
|
||||
public class Config {
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(Config.class);
|
||||
|
||||
@Value("${redis.host}")
|
||||
private String host;
|
||||
|
||||
@Value("${redis.port:6379}")
|
||||
private String port;
|
||||
|
||||
@Value("${redis.password}")
|
||||
private String password;
|
||||
|
||||
@Value("${aai.mode}")
|
||||
private String aai_mode;
|
||||
|
||||
@PostConstruct
|
||||
private void init(){
|
||||
LOGGER.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JedisConnectionFactory connectionFactory() {
|
||||
LOGGER.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
|
||||
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
|
||||
jedisConnectionFactory.setHostName(host);
|
||||
jedisConnectionFactory.setPort(Integer.parseInt(port));
|
||||
jedisConnectionFactory.setUsePool(true);
|
||||
if(password != null) jedisConnectionFactory.setPassword(password);
|
||||
return jedisConnectionFactory;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CookieSerializer cookieSerializer() {
|
||||
DefaultCookieSerializer serializer = new DefaultCookieSerializer();
|
||||
serializer.setCookieName("openAIRESession");
|
||||
serializer.setCookiePath("/");
|
||||
if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
|
||||
serializer.setDomainName(".openaire.eu");
|
||||
// serializer.setDomainName(".athenarc.gr");
|
||||
LOGGER.info("Serializer : " + 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,94 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import com.google.gson.*;
|
||||
|
||||
public class FrontEndLinkURIAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
|
||||
|
||||
private String frontEndURI;
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(FrontEndLinkURIAuthenticationSuccessHandler.class);
|
||||
|
||||
public void init(){
|
||||
LOGGER.debug("Front end uri : " + frontEndURI);
|
||||
}
|
||||
|
||||
|
||||
@Value("${aai.mode}")
|
||||
private String aai_mode;
|
||||
|
||||
@Override
|
||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
||||
|
||||
OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
|
||||
JsonObject userInfo = new JsonObject();
|
||||
|
||||
if (authOIDC.getUserInfo().getSub() == null)
|
||||
userInfo.addProperty("sub", "");
|
||||
else
|
||||
userInfo.addProperty("sub", URLEncoder.encode(authOIDC.getUserInfo().getSub(), "UTF-8"));
|
||||
|
||||
|
||||
if(authOIDC.getUserInfo().getName() != null)
|
||||
userInfo.addProperty("fullname", URLEncoder.encode(authOIDC.getUserInfo().getName(), "UTF-8"));
|
||||
|
||||
if (authOIDC.getUserInfo().getGivenName() == null)
|
||||
userInfo.addProperty("firstname", "");
|
||||
else
|
||||
userInfo.addProperty("firstname", URLEncoder.encode(authOIDC.getUserInfo().getGivenName(), "UTF-8") + "");
|
||||
|
||||
if (authOIDC.getUserInfo().getFamilyName() == null)
|
||||
userInfo.addProperty("lastname", "");
|
||||
else
|
||||
userInfo.addProperty("lastname", URLEncoder.encode(authOIDC.getUserInfo().getFamilyName(), "UTF-8") + "");
|
||||
|
||||
userInfo.addProperty("email", authOIDC.getUserInfo().getEmail() + "");
|
||||
if (authOIDC.getUserInfo().getSource().getAsJsonArray("edu_person_entitlements") == null)
|
||||
userInfo.addProperty("role", "");
|
||||
else
|
||||
userInfo.addProperty("role", URLEncoder.encode(authOIDC.getUserInfo()
|
||||
.getSource().getAsJsonArray("edu_person_entitlements").toString(), "UTF-8") + "");
|
||||
|
||||
|
||||
Cookie openAIREUser = new Cookie("openAIREUser", new Gson().toJson(userInfo) );
|
||||
openAIREUser.setMaxAge(14400);
|
||||
openAIREUser.setPath("/");
|
||||
if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
|
||||
openAIREUser .setDomain(".openaire.eu");
|
||||
// openAIREUser.setDomain(".athenarc.gr");
|
||||
response.addCookie(openAIREUser);
|
||||
|
||||
|
||||
Cookie accessToken = new Cookie("AccessToken", authOIDC.getAccessTokenValue());
|
||||
accessToken.setMaxAge(14400);
|
||||
if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
|
||||
accessToken.setDomain(".openaire.eu");
|
||||
accessToken.setPath("/");
|
||||
|
||||
// accessToken.setDomain(".athenarc.gr");
|
||||
response.addCookie(accessToken);
|
||||
response.sendRedirect(frontEndURI);
|
||||
}
|
||||
|
||||
public String getFrontEndURI() {
|
||||
return frontEndURI;
|
||||
}
|
||||
|
||||
public void setFrontEndURI(String frontEndURI) {
|
||||
this.frontEndURI = frontEndURI;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import com.nimbusds.jwt.JWT;
|
||||
import org.mitre.openid.connect.client.OIDCAuthoritiesMapper;
|
||||
import org.mitre.openid.connect.model.UserInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class OpenAireProviderAuthoritiesMapper implements OIDCAuthoritiesMapper {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(OpenAireProviderAuthoritiesMapper.class);
|
||||
|
||||
final private static String ROLE_CLAIMS = "edu_person_entitlements";
|
||||
|
||||
private Map<String,SimpleGrantedAuthority> userRolesMap;
|
||||
|
||||
OpenAireProviderAuthoritiesMapper(Map<String,String> userRoles) {
|
||||
userRolesMap = new HashMap<>();
|
||||
userRoles.forEach((openaireRole, appRole) -> userRolesMap.put(openaireRole, new SimpleGrantedAuthority(appRole)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> mapAuthorities(JWT idToken, UserInfo userInfo) {
|
||||
Set<GrantedAuthority> out = new HashSet<>();
|
||||
out.add(new SimpleGrantedAuthority("ROLE_USER"));
|
||||
|
||||
if(userInfo.getSource().getAsJsonArray(ROLE_CLAIMS) != null) {
|
||||
userInfo.getSource().getAsJsonArray(ROLE_CLAIMS).forEach(role -> {
|
||||
SimpleGrantedAuthority authority = userRolesMap.get(role.getAsString());
|
||||
if (authority != null) {
|
||||
logger.debug("Role mapped " + role);
|
||||
out.add(authority);
|
||||
}
|
||||
});
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.web.context.ContextLoaderListener;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.XmlWebApplicationContext;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import java.util.Properties;
|
||||
|
||||
public class RepoManagerContextLoaderListener extends ContextLoaderListener {
|
||||
private static Logger logger = Logger.getLogger(RepoManagerContextLoaderListener.class);
|
||||
|
||||
|
||||
public RepoManagerContextLoaderListener() {
|
||||
super();
|
||||
}
|
||||
|
||||
public RepoManagerContextLoaderListener(WebApplicationContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WebApplicationContext createWebApplicationContext(
|
||||
ServletContext servletContext)
|
||||
throws BeansException {
|
||||
logger.debug("Creating web application context");
|
||||
Properties props = this.loadProperties();
|
||||
String repoMode = props.getProperty("services.validator.mode.repo");
|
||||
String userMode = props.getProperty("services.validator.mode.user");
|
||||
Boolean standaloneMode = Boolean.parseBoolean(props.getProperty("services.validator.mode.standalone"));
|
||||
|
||||
logger.info("User mode: " + userMode);
|
||||
logger.info("Repo mode: " + repoMode);
|
||||
logger.info("Standalone mode: " + standaloneMode);
|
||||
// logger.info("Dnet workflow enabled: " + repoMode);
|
||||
XmlWebApplicationContext ctx = new XmlWebApplicationContext();
|
||||
|
||||
ctx.setServletContext(servletContext);
|
||||
|
||||
String userApiContext = null;
|
||||
if (userMode.equalsIgnoreCase("local"))
|
||||
userApiContext = "eu/dnetlib/validator/web/api/impls/users/springContext-validator-user-local.xml";
|
||||
else if (userMode.equalsIgnoreCase("ldap"))
|
||||
userApiContext = "eu/dnetlib/users/springContext-users-ldap.xml";
|
||||
|
||||
String[] springContextCore = new String[] {
|
||||
"classpath:META-INF/cxf/cxf.xml",
|
||||
"classpath:META-INF/cxf/cxf-extension-soap.xml",
|
||||
"classpath:META-INF/cxf/cxf-extension-jaxws.xml",
|
||||
"classpath:META-INF/cxf/cxf-servlet.xml",
|
||||
"classpath*:/cxf.xml",
|
||||
"classpath*:/eu/dnetlib/repos/ehcacher/springContext-repos-ehcacher.xml",
|
||||
"classpath*:/eu/dnetlib/clients/ws/springContext-locatorFactory.xml",
|
||||
"classpath*:/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.xml",
|
||||
// "classpath*:/eu/dnetlib/validator/web/actions/springContext-validator-struts.xml",
|
||||
// "classpath*:/eu/dnetlib/validator/web/actions/springContext-validator-emailer.xml",
|
||||
// "classpath*:/eu/dnetlib/validator/web/config/springContext-validator.xml",
|
||||
"classpath*:/eu/dnetlib/repo/manager/server/config/springContext-repo-manager-config.xml",
|
||||
// "classpath*:/eu/dnetlib/validator/commons/dao/springContext-*.xml",
|
||||
"classpath*:/eu/dnetlib/repos/springContext-repos-" + repoMode + ".xml",
|
||||
"classpath*:/" + userApiContext
|
||||
};
|
||||
|
||||
|
||||
String[] springContextForStandalone = new String[] {
|
||||
};
|
||||
|
||||
String[] springContextForIS = new String[] {
|
||||
"classpath*:/gr/uoa/di/driver/util/springContext-locators.xml",
|
||||
"classpath*:/gr/uoa/di/driver/app/springContext-lookupFactory.xml",
|
||||
"classpath*:/gr/uoa/di/driver/app/springContext-lookupClients.xml",
|
||||
"classpath*:/eu/dnetlib/enabling/hcm/springContext-hcmService.xml",
|
||||
"classpath*:/gr/uoa/di/driver/app/springContext-commons.xml",
|
||||
"classpath*:/gr/uoa/di/driver/app/springContext-registrator.xml"
|
||||
};
|
||||
|
||||
if (standaloneMode) {
|
||||
logger.debug("Loading contexts for standalone mode");
|
||||
ctx.setConfigLocations((String[])ArrayUtils.addAll(springContextCore,springContextForStandalone));
|
||||
} else {
|
||||
logger.debug("Loading contexts for dnet");
|
||||
ctx.setConfigLocations((String[])ArrayUtils.addAll(springContextCore,springContextForIS));
|
||||
}
|
||||
|
||||
ctx.refresh();
|
||||
|
||||
logger.debug("done");
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
private Properties loadProperties() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] {
|
||||
"classpath*:/eu/dnetlib/repo/manager/server/config/springContext-repo-manager-config.xml"
|
||||
});
|
||||
|
||||
CascadingPropertyLoader pLoader = (CascadingPropertyLoader) ctx.getBean("propertyLoader");
|
||||
Properties props = pLoader.getProperties();
|
||||
|
||||
ctx.destroy();
|
||||
ctx.close();
|
||||
return props;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import eu.dnetlib.repo.manager.controllers.*;
|
||||
import eu.dnetlib.repo.manager.service.MonitorService;
|
||||
import eu.dnetlib.repo.manager.service.PiWikService;
|
||||
import eu.dnetlib.repo.manager.service.RepositoryService;
|
||||
import eu.dnetlib.repo.manager.service.ValidatorService;
|
||||
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
|
||||
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Contact;
|
||||
import springfox.documentation.service.VendorExtension;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
/**
|
||||
* Created by panagiotis on 16/11/2017.
|
||||
*/
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
@EnableWebMvc
|
||||
@EnableCircuitBreaker
|
||||
@ComponentScan(basePackageClasses = {
|
||||
RepositoryController.class,
|
||||
MonitorController.class,
|
||||
ValidatorController.class,
|
||||
PiWikController.class,
|
||||
BrokerController.class,
|
||||
StatsController.class,
|
||||
UserController.class,
|
||||
SushiliteController.class
|
||||
},basePackages = "eu.dnetlib.repo.manager.*")
|
||||
public class SwaggerConfig {
|
||||
|
||||
@Bean
|
||||
public Docket productApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
.pathMapping("/")
|
||||
.apiInfo(getApiInfo());
|
||||
}
|
||||
|
||||
private ApiInfo getApiInfo() {
|
||||
return new ApiInfo("Repository Manager Dashboard API Documentation",
|
||||
"Repository Manager Dashboard API Documentation",
|
||||
"1.0",
|
||||
"urn:tos",
|
||||
new Contact("", "", ""),
|
||||
"Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0",
|
||||
new ArrayList<VendorExtension>());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,126 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.repo.manager.service.BrokerServiceImpl;
|
||||
import eu.dnetlib.repo.manager.shared.BrokerException;
|
||||
import eu.dnetlib.repo.manager.shared.Term;
|
||||
import eu.dnetlib.repo.manager.shared.broker.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/broker")
|
||||
@Api(description = "Broker API", tags = {"broker"})
|
||||
public class BrokerController{
|
||||
|
||||
@Autowired
|
||||
private BrokerServiceImpl brokerService;
|
||||
|
||||
|
||||
@RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public DatasourcesBroker getDatasourcesOfUser(@RequestParam("user")
|
||||
@ApiParam(value = "User email", required = true) String user,
|
||||
@RequestParam("includeShared")
|
||||
@ApiParam(value = "Include shared datasources", required = true , defaultValue = "false") String includeShared,
|
||||
@RequestParam("includeByOthers")
|
||||
@ApiParam(value = "Include datasources of other", required = true,defaultValue = "false") String includeByOthers) throws JSONException {
|
||||
return brokerService.getDatasourcesOfUser(user, includeShared, includeByOthers);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getTopicsForDatasource/{datasourceName:.+}" ,
|
||||
method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<BrowseEntry> getTopicsForDatasource(@PathVariable("datasourceName") String datasourceName) throws BrokerException{
|
||||
return brokerService.getTopicsForDatasource(datasourceName);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/advancedShowEvents/{page}/{size}" ,
|
||||
method = RequestMethod.POST,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public EventsPage advancedShowEvents(@PathVariable("page") String page,
|
||||
@PathVariable("size") String size,
|
||||
@RequestBody AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException{
|
||||
return brokerService.advancedShowEvents(page, size, advQueryObject);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/showEvents/{datasourceName:.+}/{topic}/{page}" ,
|
||||
method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public EventsPage showEvents(@RequestParam("datasourceName") String datasourceName,
|
||||
@RequestParam("topic") String topic,
|
||||
@RequestParam("page") String page,
|
||||
@RequestParam("size") String size) throws BrokerException, JSONException{
|
||||
return brokerService.showEvents(datasourceName, topic, page, size);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getSimpleSubscriptionsOfUser/{userEmail}" ,
|
||||
method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(@PathVariable("userEmail") String userEmail) throws BrokerException{
|
||||
return brokerService.getSimpleSubscriptionsOfUser(userEmail);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/subscribe" , method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER') ")
|
||||
public Subscription subscribe(@RequestBody OpenaireSubscription obj) throws BrokerException{
|
||||
return brokerService.subscribe(obj);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/unsubscribe/{subscriptionId}" , method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public ResponseEntity<Object> unsubscribe(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException{
|
||||
return brokerService.unsubscribe(subscriptionId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getSubscription/{subscriptionId}" , method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public Subscription getSubscription(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException{
|
||||
return brokerService.getSubscription(subscriptionId);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/getDnetTopics" , method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Map<String, Term> getDnetTopics() throws BrokerException{
|
||||
return brokerService.getDnetTopics();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getNotificationsBySubscriptionId/{subscriptionId}/{page}/{size}" , method = RequestMethod.GET
|
||||
,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public EventsPage getNotificationsBySubscriptionId(@PathVariable("subscriptionId") String subscriptionId,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws BrokerException{
|
||||
return brokerService.getNotificationsBySubscriptionId(subscriptionId, page, size);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
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.service.BrokerService;
|
||||
import eu.dnetlib.repo.manager.service.DashboardService;
|
||||
import eu.dnetlib.repo.manager.service.PiWikService;
|
||||
import eu.dnetlib.repo.manager.service.RepositoryService;
|
||||
import eu.dnetlib.repo.manager.shared.AggregationDetails;
|
||||
import eu.dnetlib.repo.manager.shared.BrokerException;
|
||||
import eu.dnetlib.repo.manager.shared.MetricsInfo;
|
||||
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/dashboard")
|
||||
@Api(description = "Dashboard API", tags = {"dashboard"})
|
||||
public class DashboardController {
|
||||
|
||||
@Autowired
|
||||
private DashboardService dashboardService;
|
||||
|
||||
@Autowired
|
||||
private RepositoryService repositoryService;
|
||||
|
||||
@Autowired
|
||||
private BrokerService brokerService;
|
||||
|
||||
@Autowired
|
||||
private PiWikService piWikService;
|
||||
|
||||
@RequestMapping(value = "/getRepositoriesSummary/{userEmail}/{page}/{size}" , method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public List<RepositorySummaryInfo> getRepositoriesSummaryInfo(@PathVariable("userEmail") String userEmail,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
return dashboardService.getRepositoriesSummaryInfo(userEmail, page, size);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/collectionMonitorSummary/{repoId}" , method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public CollectionMonitorSummary getCollectionMonitorSummary(
|
||||
@PathVariable("repoId") String repoId,
|
||||
@RequestParam(name = "size", required = false, defaultValue = "20") int size) throws JSONException {
|
||||
|
||||
List<AggregationDetails> aggregationDetails = repositoryService.getRepositoryAggregations(repoId,0,size);
|
||||
CollectionMonitorSummary collectionMonitorSummary = new CollectionMonitorSummary();
|
||||
collectionMonitorSummary.setAggregationDetails(aggregationDetails);
|
||||
size=0;
|
||||
do {
|
||||
aggregationDetails = repositoryService.getRepositoryAggregations(repoId,size,size+50);
|
||||
for(AggregationDetails aggregationDetail : aggregationDetails){
|
||||
if(aggregationDetail.getIndexedVersion()){
|
||||
collectionMonitorSummary.setLastIndexedVersion(aggregationDetail);
|
||||
break;
|
||||
}
|
||||
}
|
||||
size+=30;
|
||||
}while (aggregationDetails.size() != 0 && collectionMonitorSummary.getLastIndexedVersion()==null);
|
||||
|
||||
return collectionMonitorSummary;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/usageSummary/{repoId}" , method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public UsageSummary getUsageSummary(
|
||||
@PathVariable("repoId") String repoId
|
||||
) throws RepositoryServiceException {
|
||||
return new UsageSummary(repositoryService.getMetricsInfoForRepository(repoId), piWikService.getPiwikSiteForRepo(repoId));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/brokerSummary/{email}/{ds_name}" , method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public BrokerSummary getBrokerSummary(
|
||||
@PathVariable("email") String email,
|
||||
@PathVariable("ds_name") String datasourceName) throws BrokerException {
|
||||
return new BrokerSummary(brokerService.getSimpleSubscriptionsOfUser(email), brokerService.getTopicsForDatasource(datasourceName));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.EndPointException;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.exception.ServerError;
|
||||
import eu.dnetlib.repo.manager.shared.BrokerException;
|
||||
import org.apache.log4j.LogManager;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
|
||||
@ControllerAdvice
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class GenericControllerAdvice {
|
||||
|
||||
private Logger logger = LogManager.getLogger(GenericControllerAdvice.class);
|
||||
|
||||
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
@ExceptionHandler(ResourceNotFoundException.class)
|
||||
@ResponseBody
|
||||
public ServerError securityException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.FORBIDDEN)
|
||||
@ExceptionHandler(AccessDeniedException.class)
|
||||
@ResponseBody
|
||||
public ServerError accessDeniedException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
@ExceptionHandler(UnknownHostException.class)
|
||||
@ResponseBody
|
||||
public ServerError unknownHostException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ExceptionHandler({JSONException.class,BrokerException.class,ValidatorServiceException.class})
|
||||
@ResponseBody
|
||||
public ServerError internalException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.GATEWAY_TIMEOUT)
|
||||
@ExceptionHandler(EndPointException.class)
|
||||
@ResponseBody
|
||||
public ServerError endPointException(HttpServletRequest req, Exception ex) {
|
||||
return new ServerError(req.getRequestURL().toString(),ex);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import eu.dnetlib.repo.manager.service.MonitorServiceImpl;
|
||||
import eu.dnetlib.repo.manager.shared.JobsOfUser;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/monitor")
|
||||
@Api(description = "Monitor API", tags = {"monitor"})
|
||||
public class MonitorController {
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(MonitorController.class);
|
||||
|
||||
@Autowired
|
||||
private MonitorServiceImpl monitorService;
|
||||
|
||||
@RequestMapping(value = "/getJobsOfUser" , method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public JobsOfUser getJobsOfUser(@RequestParam("user") @ApiParam(value = "User email", required = true) String user,
|
||||
@RequestParam(value = "jobType", required = false)
|
||||
@ApiParam(value = "Equals to filter job type on validation history page") String jobType,
|
||||
@RequestParam("offset") @ApiParam(value = "Page number", required = true) String offset,
|
||||
@RequestParam(value = "limit", required = false,defaultValue = "10") @ApiParam(value = "Null value") String limit,
|
||||
@RequestParam(value = "dateFrom", required = false) @ApiParam(value = "Null value") String dateFrom,
|
||||
@RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo,
|
||||
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = false) String validationStatus,
|
||||
@RequestParam("includeJobsTotal") @ApiParam(value = "Always true", required = true) String includeJobsTotal) throws JSONException, ValidatorServiceException {
|
||||
|
||||
return monitorService.getJobsOfUser(user, jobType, offset, limit, dateFrom, dateTo, validationStatus, includeJobsTotal);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getJobsOfUserPerValidationStatus" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public int getJobsOfUserPerValidationStatus(@RequestBody String user,
|
||||
@RequestBody String jobType,
|
||||
@RequestBody String validationStatus) throws JSONException {
|
||||
return monitorService.getJobsOfUserPerValidationStatus(user, jobType, validationStatus);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getJobSummary" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public StoredJob getJobSummary(@RequestParam String jobId,
|
||||
@RequestParam String groupBy) throws JSONException {
|
||||
return monitorService.getJobSummary(jobId, groupBy);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,189 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.repo.manager.domain.OrderByField;
|
||||
import eu.dnetlib.repo.manager.domain.OrderByType;
|
||||
import eu.dnetlib.repo.manager.domain.Paging;
|
||||
import eu.dnetlib.repo.manager.service.PiWikServiceImpl;
|
||||
import eu.dnetlib.repo.manager.service.RepositoryService;
|
||||
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PostAuthorize;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/piwik")
|
||||
@Api(description = "Piwik API", tags = {"piwik"})
|
||||
public class PiWikController {
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(PiWikController.class);
|
||||
|
||||
@Autowired
|
||||
private PiWikServiceImpl piWikService;
|
||||
|
||||
@Autowired
|
||||
private RepositoryService repositoryService;
|
||||
|
||||
|
||||
@RequestMapping(value = "/getPiwikSiteForRepo/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#repositoryId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#repositoryId).registeredBy=='null') and hasRole('ROLE_USER'))")
|
||||
public PiwikInfo getPiwikSiteForRepo(@PathVariable("repositoryId") String repositoryId) {
|
||||
return piWikService.getPiwikSiteForRepo(repositoryId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/savePiwikInfo" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#piwikInfo.repositoryId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#piwikInfo.repositoryId).registeredBy=='null') and hasRole('ROLE_USER'))")
|
||||
public PiwikInfo savePiwikInfo(@RequestBody PiwikInfo piwikInfo) {
|
||||
return piWikService.savePiwikInfo(piwikInfo);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getPiwikSitesForRepos" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "from", dataType = "number", paramType = "query"),
|
||||
@ApiImplicitParam(name = "quantity", dataType = "number", paramType = "query"),
|
||||
@ApiImplicitParam(name = "order", dataType = "eu.dnetlib.repo.manager.domain.OrderByType", paramType = "query"),
|
||||
@ApiImplicitParam(name = "orderField", dataType = "eu.dnetlib.repo.manager.domain.OrderByField", paramType = "query"),
|
||||
@ApiImplicitParam(name = "searchField", dataType = "string", paramType = "query"),
|
||||
})
|
||||
public Paging<PiwikInfo> getPiwikSitesForRepos(
|
||||
@RequestParam(value = "from",required=false,defaultValue = "0") int from,
|
||||
@RequestParam(value = "quantity",required=false,defaultValue = "100") int quantity,
|
||||
@RequestParam(value = "order",required=false,defaultValue = "DSC") OrderByType orderType,
|
||||
@RequestParam(value = "orderField", required = false, defaultValue = "REPOSITORY_NAME") OrderByField orderField,
|
||||
@RequestParam(value = "searchField", required = false, defaultValue = "") String searchField
|
||||
|
||||
){
|
||||
Paging<PiwikInfo> results = new Paging<>();
|
||||
List<PiwikInfo> returning = piWikService.getPiwikSitesForRepos(orderField,orderType,from,quantity,searchField);
|
||||
results.setFrom(from);
|
||||
results.setTo(from + returning.size());
|
||||
results.setTotal(piWikService.getPiwikSitesTotals(searchField));
|
||||
results.setResults(returning);
|
||||
return results;
|
||||
}
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "from", dataType = "number", paramType = "query"),
|
||||
@ApiImplicitParam(name = "quantity", dataType = "number", paramType = "query"),
|
||||
@ApiImplicitParam(name = "order", dataType = "eu.dnetlib.repo.manager.domain.OrderByType", paramType = "query"),
|
||||
@ApiImplicitParam(name = "searchField", dataType = "eu.dnetlib.repo.manager.domain.OrderByField", paramType = "query"),
|
||||
@ApiImplicitParam(name = "orderField", dataType = "string", paramType = "query"),
|
||||
})
|
||||
@RequestMapping(value = "/getPiwikSitesForRepos/csv" , method = RequestMethod.GET,produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
@ResponseBody
|
||||
public FileSystemResource getPiwikSitesForReposToCsv(
|
||||
@RequestParam(value = "from",required=false,defaultValue = "0") int from,
|
||||
@RequestParam(value = "quantity",required=false,defaultValue = "10000") int quantity,
|
||||
@RequestParam(value = "order",required=false,defaultValue = "DSC") OrderByType orderType,
|
||||
@RequestParam(value = "orderField", required = false, defaultValue = "REPOSITORY_NAME") OrderByField orderField,
|
||||
@RequestParam(value = "searchField", required = false, defaultValue = "") String searchField,
|
||||
HttpServletResponse response,
|
||||
HttpServletRequest request
|
||||
) throws IOException {
|
||||
|
||||
Path p = Files.createTempFile("exportingCsv-", new Date().toString());
|
||||
List<PiwikInfo> returning = piWikService.getPiwikSitesForRepos(orderField,orderType,0,10000,searchField);
|
||||
try (PrintWriter writer = new PrintWriter(p.toFile())) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
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){
|
||||
sb.append(
|
||||
(piwikInfo.getRepositoryId() == null ? "," : piwikInfo.getRepositoryId()+ ",")+
|
||||
(piwikInfo.getRepositoryName() == null ? "," : piwikInfo.getRepositoryName()+ ",")+
|
||||
(piwikInfo.getCountry() == null ? "," : piwikInfo.getCountry()+ ",")+
|
||||
(piwikInfo.getSiteId() == null ? "," : piwikInfo.getSiteId()+ ",") +
|
||||
(piwikInfo.getAuthenticationToken() == null ? "," : piwikInfo.getAuthenticationToken()+ ",")+
|
||||
(piwikInfo.getCreationDate() == null ? "," : piwikInfo.getCreationDate().toString()+ ",") +
|
||||
(piwikInfo.getRequestorName() == null ? "," : piwikInfo.getRequestorName()+ ",") +
|
||||
(piwikInfo.getRequestorEmail() == null ? "," : piwikInfo.getRequestorEmail()+ ",")+
|
||||
piwikInfo.isValidated() + "," +
|
||||
(piwikInfo.getValidationDate() == null ? "," : piwikInfo.getValidationDate().toString()+ ",") +
|
||||
(piwikInfo.getComment() == null ? "\n" : piwikInfo.getComment()+ "\n")
|
||||
|
||||
);
|
||||
}
|
||||
writer.write(sb.toString());
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
LOGGER.error(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
String mimeType = request.getServletContext().getMimeType(p.toFile().getAbsolutePath());
|
||||
if (mimeType == null) {
|
||||
mimeType = "application/octet-stream";
|
||||
}
|
||||
response.setContentType(mimeType);
|
||||
response.setContentLength((int) p.toFile().length());
|
||||
|
||||
|
||||
String headerKey = "Content-Disposition";
|
||||
SimpleDateFormat sdfDate = new SimpleDateFormat("ddMMyyyy");//dd/MM/yyyy
|
||||
Date now = new Date();
|
||||
String strDate = sdfDate.format(now);
|
||||
String headerValue = String.format("attachment; filename=\"csv-%s.csv\"",
|
||||
strDate);
|
||||
response.setHeader(headerKey, headerValue);
|
||||
|
||||
|
||||
return new FileSystemResource(p.toFile());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/approvePiwikSite/{repositoryId}" , method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
|
||||
public ResponseEntity<Object> approvePiwikSite(@PathVariable("repositoryId") String repositoryId) {
|
||||
return piWikService.approvePiwikSite(repositoryId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getOpenaireId/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
|
||||
public String getOpenaireId(String repositoryid){
|
||||
return piWikService.getOpenaireId(repositoryid);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/markPiwikSiteAsValidated/{repositoryId}" , method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
|
||||
public ResponseEntity<Object> markPiwikSiteAsValidated(@PathVariable("repositoryId") String repositoryId) throws RepositoryServiceException {
|
||||
return piWikService.markPiwikSiteAsValidated(repositoryId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/enableMetricsForRepository", method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or (hasRole('ROLE_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)")
|
||||
public PiwikInfo enableMetricsForRepository(@RequestParam("officialName") String officialName,
|
||||
@RequestParam("repoWebsite") String repoWebsite,
|
||||
@RequestBody PiwikInfo piwikInfo) throws RepositoryServiceException {
|
||||
return piWikService.enableMetricsForRepository(officialName, repoWebsite, piwikInfo);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,227 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.service.RepositoryServiceImpl;
|
||||
import eu.dnetlib.repo.manager.shared.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.access.prepost.PostAuthorize;
|
||||
import org.springframework.security.access.prepost.PostFilter;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/repository")
|
||||
@Api(description = "Repository API", tags = {"repository"})
|
||||
public class RepositoryController {
|
||||
|
||||
@Autowired
|
||||
private RepositoryServiceImpl repositoryService;
|
||||
|
||||
@RequestMapping(value = "/getCountries", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Country[] getCountries() {
|
||||
return repositoryService.getCountries();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getRepositoriesByCountry/{country}/{mode}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<RepositorySnippet> getRepositoriesByCountry(@PathVariable("country") String country,
|
||||
@PathVariable("mode") String mode,
|
||||
@RequestParam(value = "managed",required=false) Boolean managed) throws JSONException, IOException {
|
||||
return repositoryService.getRepositoriesByCountry(country, mode, managed);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getRepositoriesOfUser/{userEmail}/{page}/{size}",method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public List<Repository> getRepositoriesOfUser(@PathVariable("userEmail") String userEmail,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
return repositoryService.getRepositoriesOfUser(userEmail, page, size);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/searchRegisteredRepositories/{page}/{size}",method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
|
||||
public List<RepositorySnippet> searchRegisteredRepositories(@RequestParam(name="country", required=false) String country,
|
||||
@RequestParam(name="typology", required=false) String typology,
|
||||
@RequestParam(name="englishName", required=false) String englishName,
|
||||
@RequestParam(name="officialName", required=false) String officialName,
|
||||
@RequestParam("requestSortBy") String requestSortBy,
|
||||
@RequestParam("order") String order,
|
||||
@PathVariable("page") int page,
|
||||
@PathVariable("size") int pageSize) throws Exception {
|
||||
|
||||
return repositoryService.searchRegisteredRepositories(country, typology, englishName, officialName, requestSortBy, order, page, pageSize);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getRepositoryById/{id}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PostAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((returnObject.registeredBy=='null' or returnObject.registeredBy==authentication.userInfo.email) and hasRole('ROLE_USER'))")
|
||||
public Repository getRepositoryById(@PathVariable("id") String id) throws JSONException,ResourceNotFoundException {
|
||||
Repository repo = repositoryService.getRepositoryById(id);
|
||||
return repo;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getRepositoryAggregations/{id}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<AggregationDetails> getRepositoryAggregations(@PathVariable("id") String id) throws JSONException {
|
||||
return repositoryService.getRepositoryAggregations(id,0,20);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getRepositoryAggregationsByYear/{id}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Map<String, List<AggregationDetails>> getRepositoryAggregationsByYear(@PathVariable("id") String id) throws JSONException {
|
||||
return repositoryService.getRepositoryAggregationsByYear(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getRepositoriesByName/{name:.+}/{page}/{size}/", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<Repository> getRepositoriesByName(@PathVariable("name") String name,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
return repositoryService.getRepositoriesByName(name, page, size);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getRepositoryInterface/{id}", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PostAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#id).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#id).registeredBy=='null' ) and hasRole('ROLE_USER'))")
|
||||
public List<RepositoryInterface> getRepositoryInterface(@PathVariable("id") String id) throws JSONException {
|
||||
return repositoryService.getRepositoryInterface(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/addRepository", method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((#repository.registeredBy==authentication.userInfo.email or returnObject.registeredBy=='null') and hasRole('ROLE_USER'))")
|
||||
public Repository addRepository(@RequestParam("datatype") String datatype,
|
||||
@RequestBody Repository repository) throws Exception {
|
||||
|
||||
return repositoryService.addRepository(datatype, repository);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getDnetCountries", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<String> getDnetCountries(){
|
||||
return repositoryService.getDnetCountries();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getTypologies", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<String> getTypologies(){
|
||||
return repositoryService.getTypologies();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getTimezones", method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<Timezone> getTimezones(){
|
||||
return repositoryService.getTimezones();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateRepository", method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((#repository.registeredBy==authentication.userInfo.email or #repository.registeredBy=='null') and hasRole('ROLE_USER'))")
|
||||
public Repository updateRepository(@RequestBody Repository repository,Authentication authentication) throws Exception {
|
||||
return repositoryService.updateRepository(repository, authentication);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/deleteInterface/", method = RequestMethod.DELETE)
|
||||
@PreAuthorize("hasRole('ROLE_USER') and #registeredBy == authentication.userInfo.email")
|
||||
public void deleteRepositoryInterface(@RequestParam("id") String id ,
|
||||
@RequestParam("registeredBy") String registeredBy){
|
||||
repositoryService.deleteRepositoryInterface(id, registeredBy);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/addInterface", method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#repoId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#repoId).registeredBy=='null') and hasRole('ROLE_USER'))")
|
||||
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
|
||||
@RequestParam("repoId") String repoId,
|
||||
@RequestParam("registeredBy") String registeredBy,
|
||||
@RequestBody RepositoryInterface repositoryInterface) throws JSONException, ResourceNotFoundException, ValidatorServiceException {
|
||||
return repositoryService.addRepositoryInterface(datatype, repoId, registeredBy, repositoryInterface);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getUrlsOfUserRepos/{user_email}/{page}/{size}/",method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public List<String> getUrlsOfUserRepos(@PathVariable("user_email") String userEmail,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
return repositoryService.getUrlsOfUserRepos(userEmail, page, size);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getDatasourceVocabularies/{mode}",method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<String> getDatasourceVocabularies(@PathVariable("mode") String mode) {
|
||||
return repositoryService.getDatasourceVocabularies(mode);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getCompatibilityClasses/{mode}",method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Map<String, String> getCompatibilityClasses(@PathVariable("mode") String mode) {
|
||||
|
||||
return repositoryService.getCompatibilityClasses(mode);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getDatasourceClasses/{mode}",method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Map<String, String> getDatasourceClasses(@PathVariable("mode") String mode) {
|
||||
return repositoryService.getDatasourceClasses(mode);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getMetricsInfoForRepository/{repoId}",method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public MetricsInfo getMetricsInfoForRepository(@PathVariable("repoId") String repoId) throws RepositoryServiceException {
|
||||
return repositoryService.getMetricsInfoForRepository(repoId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getListLatestUpdate/{mode}",method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Map<String, String> getListLatestUpdate(@PathVariable("mode") String mode) throws JSONException {
|
||||
return repositoryService.getListLatestUpdate(mode);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateRepositoryInterface", method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#repoId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#repoId).registeredBy=='null') and hasRole('ROLE_USER'))")
|
||||
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String repoId,
|
||||
@RequestParam("registeredBy") String registeredBy,
|
||||
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
||||
return repositoryService.updateRepositoryInterface(repoId, registeredBy, repositoryInterface);
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.repo.manager.exception.EndPointException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.ResponseErrorHandler;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.springframework.http.HttpStatus.Series.CLIENT_ERROR;
|
||||
import static org.springframework.http.HttpStatus.Series.SERVER_ERROR;
|
||||
|
||||
@Component
|
||||
public class RestTemplateResponseErrorHandler implements ResponseErrorHandler {
|
||||
|
||||
@Override
|
||||
public boolean hasError(ClientHttpResponse httpResponse) throws IOException {
|
||||
return (httpResponse.getStatusCode().series() == CLIENT_ERROR
|
||||
|| httpResponse.getStatusCode().series() == SERVER_ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleError(ClientHttpResponse httpResponse) throws IOException {
|
||||
|
||||
if (httpResponse.getStatusCode().series() == HttpStatus.Series.SERVER_ERROR) {
|
||||
throw new EndPointException();
|
||||
} else if (httpResponse.getStatusCode().series() == HttpStatus.Series.CLIENT_ERROR) {
|
||||
if (httpResponse.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||
throw new IOException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.repo.manager.service.StatsServiceImpl;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/stats")
|
||||
@Api(description = "Stats API", tags = {"statistics"})
|
||||
public class StatsController {
|
||||
|
||||
@Autowired
|
||||
private StatsServiceImpl statsService;
|
||||
|
||||
@RequestMapping(value = "/getStatistics" , method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Map getStatistics(){
|
||||
return statsService.getStatistics();
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.repo.manager.service.SushiliteServiceImpl;
|
||||
import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/sushilite")
|
||||
@Api(description = "Sushi-Lite API", tags = {"sushilite"})
|
||||
public class SushiliteController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private SushiliteServiceImpl sushiliteService;
|
||||
|
||||
@RequestMapping(value = "/getReportResults/{page}/{pageSize}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public ReportResponseWrapper getReportResults(@PathVariable("page") String page,
|
||||
@PathVariable("pageSize") String pageSize,
|
||||
@RequestParam(value = "Report") String Report,
|
||||
@RequestParam(value = "Release",defaultValue="4") String Release,
|
||||
@RequestParam(value = "RequestorID",required=false,defaultValue="anonymous") String RequestorID,
|
||||
@RequestParam(value = "BeginDate",required=false,defaultValue="") String BeginDate,
|
||||
@RequestParam(value = "EndDate",required=false,defaultValue="") String EndDate,
|
||||
@RequestParam(value = "RepositoryIdentifier") String RepositoryIdentifier,
|
||||
@RequestParam(value = "ItemIdentifier",required=false,defaultValue="") String ItemIdentifier,
|
||||
@RequestParam(value = "ItemDataType",required=false,defaultValue="") String ItemDataType,
|
||||
@RequestParam(value = "Granularity") String Granularity,
|
||||
@RequestParam(value = "Pretty",required=false,defaultValue="") String Pretty) {
|
||||
|
||||
return sushiliteService.getReportResults(page, pageSize, Report, Release, RequestorID, BeginDate, EndDate, RepositoryIdentifier, ItemIdentifier, ItemDataType, Granularity, Pretty);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.repo.manager.service.UserServiceImpl;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/user")
|
||||
@Api(description = "User API", tags = {"user"})
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private UserServiceImpl userService;
|
||||
|
||||
@RequestMapping(value = "/login" , method = RequestMethod.GET)
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public ResponseEntity<Object> login() {
|
||||
return userService.login();
|
||||
}
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.domain.functionality.validator.JobResultEntry;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.service.EmailUtils;
|
||||
import eu.dnetlib.repo.manager.service.RepositoryService;
|
||||
import eu.dnetlib.repo.manager.service.ValidatorServiceImpl;
|
||||
import eu.dnetlib.repo.manager.shared.InterfaceInformation;
|
||||
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/validator")
|
||||
@Api(description = "Validator API", tags = {"validator"})
|
||||
public class ValidatorController {
|
||||
|
||||
@Autowired
|
||||
private ValidatorServiceImpl validatorService;
|
||||
|
||||
@Autowired
|
||||
private EmailUtils emailUtils;
|
||||
|
||||
@RequestMapping(value = "/submitJobForValidation",method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER') and #jobForValidation.userEmail == authentication.userInfo.email")
|
||||
public JobForValidation submitJobForValidation(@RequestBody JobForValidation jobForValidation) throws ValidatorServiceException {
|
||||
return validatorService.submitJobForValidation(jobForValidation);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/reSubmitJobForValidation/{email}/{jobId}",method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER') and #email == authentication.userInfo.email")
|
||||
public ResponseEntity<Object> reSubmitJobForValidation(@PathVariable("email") String email,
|
||||
@PathVariable("jobId") String jobId) throws JSONException, ValidatorServiceException {
|
||||
return validatorService.reSubmitJobForValidation(email, jobId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getRuleSets/{mode}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<RuleSet> getRuleSets(@PathVariable("mode") String mode) {
|
||||
return validatorService.getRuleSets(mode);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getSetsOfRepository" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<String> getSetsOfRepository(@RequestParam(value = "url", required = true) String url) {
|
||||
return validatorService.getSetsOfRepository(url);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/identifyRepository" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public boolean identifyRepo(@RequestParam(value = "url", required = true) String url) {
|
||||
return validatorService.identifyRepo(url);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getRuleSet/{acronym}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public RuleSet getRuleSet(@PathVariable("acronym") String acronym) {
|
||||
return validatorService.getRuleSet(acronym);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getStoredJobsNew" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public List<StoredJob> getStoredJobsNew(@RequestParam("user") @ApiParam(value = "User email", required = true) String user,
|
||||
@RequestParam(value = "jobType", required = false)
|
||||
@ApiParam(value = "Equals to filter job type on validation history page") String jobType,
|
||||
@RequestParam("offset") @ApiParam(value = "Page number", required = true) String offset,
|
||||
@RequestParam(value = "limit", required = false,defaultValue = "10") @ApiParam(value = "Null value") String limit,
|
||||
@RequestParam(value = "dateFrom", required = false) @ApiParam(value = "Null value") String dateFrom,
|
||||
@RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo,
|
||||
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = true) String validationStatus
|
||||
) throws ValidatorServiceException {
|
||||
return validatorService.getStoredJobsNew(user, jobType, offset, limit, dateFrom, dateTo, validationStatus);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getStoredJobsTotalNumberNew" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public int getStoredJobsTotalNumberNew(String user, String jobType, String validationStatus) throws ValidatorServiceException {
|
||||
return validatorService.getStoredJobsTotalNumberNew(user, jobType, validationStatus);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getInterfaceInformation" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public InterfaceInformation getInterfaceInformation(@RequestParam(value = "baseUrl") String baseUrl) throws ValidationServiceException {
|
||||
return validatorService.getInterfaceInformation(baseUrl);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/validationSummary/{repoId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<StoredJob> getInterfaceInformation(@PathVariable(value = "repoId") String repoId, @RequestParam(name = "size", defaultValue = "20") int size ) throws ValidatorServiceException, ResourceNotFoundException, JSONException {
|
||||
return validatorService.getJobsSummary(repoId,size);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/complete" , method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public void validationCompleted(
|
||||
@RequestParam(value = "interfaceId") String interfaceId,
|
||||
@RequestParam(value = "repoId") String repoId,
|
||||
@RequestParam(value = "jobId") String jobId,
|
||||
@RequestParam(value = "issuerEmail") String issuerEmail,
|
||||
@RequestParam(value = "isUpdate") boolean isUpdate,
|
||||
@RequestParam(value = "isSuccess") boolean isSuccess,
|
||||
@RequestParam(value = "scoreUsage") int scoreUsage,
|
||||
@RequestParam(value = "scoreContent") int scoreContent) throws Exception {
|
||||
|
||||
emailUtils.sendUponJobCompletion(repoId,interfaceId,scoreUsage,scoreContent,isSuccess,isUpdate,issuerEmail, jobId);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import eu.dnetlib.repo.manager.shared.broker.BrowseEntry;
|
||||
import eu.dnetlib.repo.manager.shared.broker.SimpleSubscriptionDesc;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BrokerSummary {
|
||||
private Map<String, List<SimpleSubscriptionDesc>> userSubs;
|
||||
|
||||
private List<BrowseEntry> topicsForDatasource;
|
||||
|
||||
public BrokerSummary(){}
|
||||
|
||||
public BrokerSummary(Map<String, List<SimpleSubscriptionDesc>> userSubs, List<BrowseEntry> topicsForDatasource) {
|
||||
this.userSubs = userSubs;
|
||||
this.topicsForDatasource = topicsForDatasource;
|
||||
}
|
||||
|
||||
public Map<String, List<SimpleSubscriptionDesc>> getUserSubs() {
|
||||
return userSubs;
|
||||
}
|
||||
|
||||
public void setUserSubs(Map<String, List<SimpleSubscriptionDesc>> userSubs) {
|
||||
this.userSubs = userSubs;
|
||||
}
|
||||
|
||||
public List<BrowseEntry> getTopicsForDatasource() {
|
||||
return topicsForDatasource;
|
||||
}
|
||||
|
||||
public void setTopicsForDatasource(List<BrowseEntry> topicsForDatasource) {
|
||||
this.topicsForDatasource = topicsForDatasource;
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import eu.dnetlib.repo.manager.shared.AggregationDetails;
|
||||
import eu.dnetlib.repo.manager.shared.broker.BrowseEntry;
|
||||
import eu.dnetlib.repo.manager.shared.broker.SimpleSubscriptionDesc;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CollectionMonitorSummary {
|
||||
private List<AggregationDetails> aggregationDetails;
|
||||
|
||||
private AggregationDetails lastIndexedVersion;
|
||||
|
||||
public CollectionMonitorSummary(){}
|
||||
|
||||
public CollectionMonitorSummary(List<AggregationDetails> aggregationDetails, AggregationDetails lastIndexedVersion) {
|
||||
this.aggregationDetails = aggregationDetails;
|
||||
this.lastIndexedVersion = lastIndexedVersion;
|
||||
}
|
||||
|
||||
public List<AggregationDetails> getAggregationDetails() {
|
||||
return aggregationDetails;
|
||||
}
|
||||
|
||||
public void setAggregationDetails(List<AggregationDetails> aggregationDetails) {
|
||||
this.aggregationDetails = aggregationDetails;
|
||||
}
|
||||
|
||||
public AggregationDetails getLastIndexedVersion() {
|
||||
return lastIndexedVersion;
|
||||
}
|
||||
|
||||
public void setLastIndexedVersion(AggregationDetails lastIndexedVersion) {
|
||||
this.lastIndexedVersion = lastIndexedVersion;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
public enum OrderByField {
|
||||
|
||||
REPOSITORY_NAME("repositoryname"),
|
||||
REPOSITORY_ID("repositoryid"),
|
||||
SITE_ID("siteid"),
|
||||
CREATION_DATE("creationdate"),
|
||||
VALIDATION_DATE("validationdate"),
|
||||
REQUESTOR_NAME("requestorname"),
|
||||
REQUESTOR_EMAIL("requestoremail"),
|
||||
VALIDATED("validated"),
|
||||
COUNTRY("country");
|
||||
|
||||
|
||||
private final String text;
|
||||
|
||||
OrderByField(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return text;
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
public enum OrderByType {
|
||||
|
||||
ASC("ASC"),
|
||||
DSC("DESC");
|
||||
|
||||
private final String text;
|
||||
|
||||
OrderByType(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return text;
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Organization implements Serializable {
|
||||
private String country;
|
||||
private String legalname;
|
||||
private String websiteurl;
|
||||
private String legalshortname;
|
||||
private String logourl;
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getLegalname() {
|
||||
return legalname;
|
||||
}
|
||||
|
||||
public void setLegalname(String legalname) {
|
||||
this.legalname = legalname;
|
||||
}
|
||||
|
||||
public String getWebsiteurl() {
|
||||
return websiteurl;
|
||||
}
|
||||
|
||||
public void setWebsiteurl(String websiteurl) {
|
||||
this.websiteurl = websiteurl;
|
||||
}
|
||||
|
||||
public String getLegalshortname() {
|
||||
return legalshortname;
|
||||
}
|
||||
|
||||
public void setLegalshortname(String legalshortname) {
|
||||
this.legalshortname = legalshortname;
|
||||
}
|
||||
|
||||
public String getLogourl() {
|
||||
return logourl;
|
||||
}
|
||||
|
||||
public void setLogourl(String logourl) {
|
||||
this.logourl = logourl;
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Paging<T> {
|
||||
|
||||
private int total;
|
||||
|
||||
private int from;
|
||||
|
||||
private int to;
|
||||
|
||||
private List<T> results;
|
||||
|
||||
public Paging(int total, int from, int to, List<T> results) {
|
||||
this.total = total;
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
public Paging(@NotNull Paging<T> page) {
|
||||
this.total = page.getTotal();
|
||||
this.from = page.getFrom();
|
||||
this.to = page.getTo();
|
||||
this.results = page.getResults();
|
||||
}
|
||||
|
||||
public <K> Paging(@NotNull Paging<K> page, List<T> results) {
|
||||
this.total = page.getTotal();
|
||||
this.from = page.getFrom();
|
||||
this.to = page.getTo();
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
public Paging() {
|
||||
this.total = 0;
|
||||
this.from = 0;
|
||||
this.to = 0;
|
||||
this.results = new ArrayList<>();
|
||||
}
|
||||
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(int total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public int getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(int from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public int getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public void setTo(int to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public List<T> getResults() {
|
||||
return results;
|
||||
}
|
||||
|
||||
public void setResults(List<T> results) {
|
||||
this.results = results;
|
||||
}
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
public class RepositorySnippet implements IsSerializable {
|
||||
|
||||
private String id;
|
||||
private String officialname;
|
||||
private String englishname;
|
||||
private String websiteurl;
|
||||
private String typology;
|
||||
private String registeredby;
|
||||
private Organization[] organizations;
|
||||
private String registrationdate;
|
||||
|
||||
public RepositorySnippet() {}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getOfficialname() {
|
||||
return officialname;
|
||||
}
|
||||
|
||||
public void setOfficialname(String officialname) {
|
||||
this.officialname = officialname;
|
||||
}
|
||||
|
||||
public String getEnglishname() {
|
||||
return englishname;
|
||||
}
|
||||
|
||||
public void setEnglishname(String englishname) {
|
||||
this.englishname = englishname;
|
||||
}
|
||||
|
||||
public String getWebsiteurl() {
|
||||
return websiteurl;
|
||||
}
|
||||
|
||||
public void setWebsiteurl(String websiteurl) {
|
||||
this.websiteurl = websiteurl;
|
||||
}
|
||||
|
||||
public String getRegisteredby() {
|
||||
return registeredby;
|
||||
}
|
||||
|
||||
public void setRegisteredby(String registeredby) {
|
||||
this.registeredby = registeredby;
|
||||
}
|
||||
|
||||
public String getTypology() {
|
||||
return typology;
|
||||
}
|
||||
|
||||
public void setTypology(String typology) {
|
||||
this.typology = typology;
|
||||
}
|
||||
|
||||
public Organization[] getOrganizations() {
|
||||
return organizations;
|
||||
}
|
||||
|
||||
public void setOrganizations(Organization[] organizations) {
|
||||
this.organizations = organizations;
|
||||
}
|
||||
|
||||
public String getRegistrationdate() {
|
||||
return registrationdate;
|
||||
}
|
||||
|
||||
public void setRegistrationdate(String registrationdate) {
|
||||
this.registrationdate = registrationdate;
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class RepositorySummaryInfo implements IsSerializable {
|
||||
|
||||
String id;
|
||||
String repositoryName;
|
||||
String logoURL;
|
||||
int recordsCollected;
|
||||
Date lastIndexedVersion;
|
||||
long enrichmentEvents;
|
||||
String totalViews;
|
||||
String totalDownloads;
|
||||
|
||||
public RepositorySummaryInfo() {
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getRepositoryName() {
|
||||
return repositoryName;
|
||||
}
|
||||
|
||||
public void setRepositoryName(String repositoryName) {
|
||||
this.repositoryName = repositoryName;
|
||||
}
|
||||
|
||||
public String getLogoURL() {
|
||||
return logoURL;
|
||||
}
|
||||
|
||||
public void setLogoURL(String logoURL) {
|
||||
this.logoURL = logoURL;
|
||||
}
|
||||
|
||||
public int getRecordsCollected() {
|
||||
return recordsCollected;
|
||||
}
|
||||
|
||||
public void setRecordsCollected(int recordsCollected) {
|
||||
this.recordsCollected = recordsCollected;
|
||||
}
|
||||
|
||||
public Date getLastIndexedVersion() {
|
||||
return lastIndexedVersion;
|
||||
}
|
||||
|
||||
public void setLastIndexedVersion(Date lastIndexedVersion) {
|
||||
this.lastIndexedVersion = lastIndexedVersion;
|
||||
}
|
||||
|
||||
public long getEnrichmentEvents() {
|
||||
return enrichmentEvents;
|
||||
}
|
||||
|
||||
public void setEnrichmentEvents(long enrichmentEvents) {
|
||||
this.enrichmentEvents = enrichmentEvents;
|
||||
}
|
||||
|
||||
public String getTotalViews() {
|
||||
return totalViews;
|
||||
}
|
||||
|
||||
public void setTotalViews(String totalViews) {
|
||||
this.totalViews = totalViews;
|
||||
}
|
||||
|
||||
public String getTotalDownloads() {
|
||||
return totalDownloads;
|
||||
}
|
||||
|
||||
public void setTotalDownloads(String totalDownloads) {
|
||||
this.totalDownloads = totalDownloads;
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class RequestFilter{
|
||||
|
||||
private String registeredby = null;
|
||||
private String typology = null;
|
||||
private String country = null;
|
||||
private String id = null;
|
||||
private String officialname = null;
|
||||
private String englishname = null;
|
||||
private String collectedfrom = null;
|
||||
|
||||
|
||||
|
||||
|
||||
public RequestFilter() {
|
||||
|
||||
}
|
||||
|
||||
public String getTypology() {
|
||||
return typology;
|
||||
}
|
||||
|
||||
public void setTypology(String typology) {
|
||||
this.typology = typology;
|
||||
}
|
||||
|
||||
public String getRegisteredby() {
|
||||
return registeredby;
|
||||
}
|
||||
|
||||
public void setRegisteredby(String registeredby) {
|
||||
this.registeredby = registeredby;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getOfficialname() {
|
||||
return officialname;
|
||||
}
|
||||
|
||||
public void setOfficialname(String officialname) {
|
||||
this.officialname = officialname;
|
||||
}
|
||||
|
||||
public String getCollectedfrom() {
|
||||
return collectedfrom;
|
||||
}
|
||||
|
||||
public void setCollectedfrom(String collectedfrom) {
|
||||
this.collectedfrom = collectedfrom;
|
||||
}
|
||||
|
||||
public String getEnglishname() {
|
||||
return englishname;
|
||||
}
|
||||
|
||||
public void setEnglishname(String englishname) {
|
||||
this.englishname = englishname;
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.repo.manager.shared.MetricsInfo;
|
||||
import eu.dnetlib.repo.manager.shared.broker.BrowseEntry;
|
||||
import eu.dnetlib.repo.manager.shared.broker.SimpleSubscriptionDesc;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class UsageSummary {
|
||||
private MetricsInfo metricsInfo;
|
||||
|
||||
private PiwikInfo piwikInfo;
|
||||
|
||||
public UsageSummary() {
|
||||
}
|
||||
|
||||
public UsageSummary(MetricsInfo metricsInfo, PiwikInfo piwikInfo) {
|
||||
this.metricsInfo = metricsInfo;
|
||||
this.piwikInfo = piwikInfo;
|
||||
}
|
||||
|
||||
public MetricsInfo getMetricsInfo() {
|
||||
return metricsInfo;
|
||||
}
|
||||
|
||||
public void setMetricsInfo(MetricsInfo metricsInfo) {
|
||||
this.metricsInfo = metricsInfo;
|
||||
}
|
||||
|
||||
public PiwikInfo getPiwikInfo() {
|
||||
return piwikInfo;
|
||||
}
|
||||
|
||||
public void setPiwikInfo(PiwikInfo piwikInfo) {
|
||||
this.piwikInfo = piwikInfo;
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.exception;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
//@ResponseStatus(HttpStatus.GATEWAY_TIMEOUT)
|
||||
public class EndPointException extends IOException {
|
||||
|
||||
public EndPointException() {
|
||||
super("Endpoint not responding!");
|
||||
}
|
||||
|
||||
public EndPointException(String url) {
|
||||
super("Endpoint with url: " + url + " not responding!");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.exception;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
public class ResourceNotFoundException extends Exception {
|
||||
public ResourceNotFoundException() {
|
||||
super("Resource Not Found");
|
||||
}
|
||||
|
||||
public ResourceNotFoundException(String id, String resourceType) {
|
||||
super(resourceType + " with id " + id + " was not found");
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.exception;
|
||||
|
||||
public class ServerError {
|
||||
|
||||
public final String url;
|
||||
public final String error;
|
||||
|
||||
public ServerError(String url, Exception ex) {
|
||||
this.url = url;
|
||||
this.error = ex.getMessage();
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
public String getError() {
|
||||
return this.error;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.repo.manager.shared.BrokerException;
|
||||
import eu.dnetlib.repo.manager.shared.Term;
|
||||
import eu.dnetlib.repo.manager.shared.broker.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public interface BrokerService {
|
||||
|
||||
DatasourcesBroker getDatasourcesOfUser(String user, String includeShared, String includeByOthers) throws BrokerException, JSONException;
|
||||
|
||||
List<BrowseEntry> getTopicsForDatasource(String datasourceName) throws BrokerException;
|
||||
|
||||
EventsPage advancedShowEvents(String page,
|
||||
String size,
|
||||
AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException;
|
||||
|
||||
EventsPage showEvents(String datasourceName,
|
||||
String topic,
|
||||
String page,
|
||||
String size) throws BrokerException, JSONException;
|
||||
|
||||
Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(String userEmail) throws BrokerException;
|
||||
|
||||
Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUserByRepoId(String userEmail, String repoId) throws BrokerException;
|
||||
|
||||
Subscription subscribe(OpenaireSubscription obj) throws BrokerException;
|
||||
|
||||
ResponseEntity<Object> unsubscribe(String subscriptionId) throws BrokerException;
|
||||
|
||||
Subscription getSubscription(String subscriptionId) throws BrokerException;
|
||||
|
||||
Map<String, Term> getDnetTopics() throws BrokerException;
|
||||
|
||||
EventsPage getNotificationsBySubscriptionId(String subscriptionId, String page, String size) throws BrokerException;
|
||||
|
||||
Map<String, List<Subscription>> getSubscriptionsOfUser(String userEmail) throws BrokerException;
|
||||
}
|
|
@ -1,397 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.repo.manager.shared.BrokerException;
|
||||
import eu.dnetlib.repo.manager.shared.Term;
|
||||
import eu.dnetlib.repo.manager.shared.Tuple;
|
||||
import eu.dnetlib.repo.manager.shared.broker.*;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
|
||||
@Service("brokerService")
|
||||
public class BrokerServiceImpl implements BrokerService {
|
||||
|
||||
@Autowired
|
||||
private RepositoryServiceImpl repoAPI;
|
||||
@Value("${services.broker.url}:${services.broker.port}/${services.broker.api}${services.broker.openaire}")
|
||||
private String openairePath;
|
||||
@Value("${services.broker.url}:${services.broker.port}/${services.broker.api}")
|
||||
private String apiPath;
|
||||
@Value("${topic_types.url}")
|
||||
private String topicsURL;
|
||||
|
||||
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger
|
||||
.getLogger(BrokerServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
RestTemplate restTemplate ;
|
||||
|
||||
private HttpHeaders httpHeaders;
|
||||
|
||||
private HashMap<String,Term> topics = new HashMap<String, Term>();
|
||||
|
||||
@Autowired
|
||||
private EmailUtils emailUtils;
|
||||
|
||||
@PostConstruct
|
||||
private void initDnetTopicsMap() {
|
||||
|
||||
httpHeaders = new HttpHeaders();
|
||||
httpHeaders.set("Content-Type", "application/json");
|
||||
|
||||
LOGGER.debug("Init dnet topics!");
|
||||
try (InputStream is = new URL(topicsURL).openStream() ){
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode root = mapper.readTree(is);
|
||||
for (JsonNode term : root.path("terms") )
|
||||
topics.put(term.path("code").textValue(), parseTerm(term));
|
||||
} catch (IOException e) {
|
||||
LOGGER.debug("Exception on initDnetTopicsMap" , e);
|
||||
emailUtils.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Term parseTerm(JsonNode term) {
|
||||
return new Term(term.path("englishName").textValue(),term.path("nativeName").textValue(),
|
||||
term.path("encoding").textValue(),term.path("code").textValue());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DatasourcesBroker getDatasourcesOfUser(String user,String includeShared,String includeByOthers) throws JSONException {
|
||||
|
||||
DatasourcesBroker ret = new DatasourcesBroker();
|
||||
try {
|
||||
ret.setDatasourcesOfUser(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
|
||||
//TODO fix bug when values are true
|
||||
if (Boolean.parseBoolean(includeShared)) {
|
||||
List<String> sharedDatasourceIds = new ArrayList<String>();
|
||||
ret.setSharedDatasources(getDatasourcesOfUserType(getRepositoriesByIds(sharedDatasourceIds)));
|
||||
}
|
||||
|
||||
if (Boolean.parseBoolean(includeByOthers)) {
|
||||
ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
|
||||
}
|
||||
} catch (BrokerException e) {
|
||||
LOGGER.debug("Exception on getDatasourcesOfUser" , e);
|
||||
emailUtils.reportException(e);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BrowseEntry> getTopicsForDatasource(String datasourceName) throws BrokerException {
|
||||
final String service = "/topicsForDatasource";
|
||||
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
||||
.queryParam("ds", datasourceName);
|
||||
|
||||
ResponseEntity<List<BrowseEntry>> resp;
|
||||
try {
|
||||
resp = restTemplate.exchange(
|
||||
builder.build().encode().toUri(),
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
new ParameterizedTypeReference<List<BrowseEntry>>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on getTopicsForDatasource" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
|
||||
return resp.getBody();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventsPage advancedShowEvents(String page,
|
||||
String size,
|
||||
AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException {
|
||||
|
||||
final String service = "/events/{page}/{pageSize}";
|
||||
|
||||
Map<String, Long> uriParams = new HashMap<>();
|
||||
uriParams.put("page", Long.parseLong(page));
|
||||
uriParams.put("pageSize", Long.parseLong(size));
|
||||
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service);
|
||||
|
||||
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
|
||||
advQueryObject.setPage(Long.parseLong(page));
|
||||
HttpEntity<AdvQueryObject> entity = new HttpEntity<>(advQueryObject, httpHeaders);
|
||||
ResponseEntity<EventsPage> resp;
|
||||
try {
|
||||
resp = restTemplate.exchange(
|
||||
builder.buildAndExpand(uriParams).encode().toUri(),
|
||||
HttpMethod.POST,
|
||||
entity,
|
||||
new ParameterizedTypeReference<EventsPage>() {
|
||||
}
|
||||
);
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on advancedShowEvents" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
return resp.getBody();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private List<Tuple<BrowseEntry, String>> getDatasourcesOfUserType(List<Repository> repositories) throws BrokerException {
|
||||
|
||||
List<Tuple<BrowseEntry, String>> entries = new ArrayList<>();
|
||||
for (Repository repo : repositories) {
|
||||
BrowseEntry temp = new BrowseEntry();
|
||||
temp.setValue(repo.getOfficialName());
|
||||
temp.setSize(new Long(0));
|
||||
for (BrowseEntry e : getTopicsForDatasource(repo.getOfficialName())) {
|
||||
temp.setSize(temp.getSize() + e.getSize());
|
||||
}
|
||||
Tuple<BrowseEntry, String> tup = new Tuple<>(temp, repo.getLogoUrl());
|
||||
entries.add(tup);
|
||||
}
|
||||
|
||||
// sort the collection by the second field of the tuple which is size
|
||||
Collections.sort(entries, new Comparator<Tuple<BrowseEntry, String>>() {
|
||||
@Override
|
||||
public int compare(Tuple<BrowseEntry, String> e1, Tuple<BrowseEntry, String> e2) {
|
||||
return (int) (e2.getFirst().getSize().longValue() - e1.getFirst().getSize().longValue());
|
||||
}
|
||||
});
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
private List<Repository> getRepositoriesOfUser(String userEmail) throws JSONException {
|
||||
|
||||
int page = 0;
|
||||
int size = 50;
|
||||
List<Repository> rs ;
|
||||
List<Repository> resultSet = new ArrayList<>();
|
||||
|
||||
while (true){
|
||||
rs = repoAPI.getRepositoriesOfUser(userEmail, String.valueOf(page), String.valueOf(size));
|
||||
resultSet.addAll(rs);
|
||||
page+=1;
|
||||
if(rs.size() == 0) break;
|
||||
}
|
||||
return resultSet;
|
||||
}
|
||||
|
||||
private List<Repository> getRepositoriesByIds(List<String> sharedDatasourceIds) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventsPage showEvents(String datasourceName,
|
||||
String topic,
|
||||
String page,
|
||||
String size) throws BrokerException, JSONException {
|
||||
|
||||
final String service = "/events";
|
||||
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
||||
.queryParam("ds", datasourceName)
|
||||
.queryParam("topic", topic)
|
||||
.path("/{page}/{size}/");
|
||||
|
||||
ResponseEntity<EventsPage> resp;
|
||||
try {
|
||||
resp = restTemplate.exchange(
|
||||
builder.build().expand(page, size).encode().toUri(),
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
new ParameterizedTypeReference<EventsPage>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on showEvents" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
return resp.getBody();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(String userEmail)
|
||||
throws BrokerException {
|
||||
|
||||
final String service = "/subscriptions";
|
||||
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
||||
.queryParam("email", userEmail);
|
||||
|
||||
LOGGER.debug(builder.build().encode().toUri());
|
||||
ResponseEntity<Map<String, List<SimpleSubscriptionDesc>>> resp;
|
||||
try {
|
||||
resp = restTemplate.exchange(
|
||||
builder.build().encode().toUri(),
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
new ParameterizedTypeReference<Map<String, List<SimpleSubscriptionDesc>>>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on getSimpleSubscriptionsOfUser" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
return resp.getBody();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUserByRepoId(String userEmail, String repoId) throws BrokerException {
|
||||
Map<String, List<SimpleSubscriptionDesc>> subscriptionsOfUser = getSimpleSubscriptionsOfUser(userEmail);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Subscription subscribe(OpenaireSubscription obj) throws BrokerException {
|
||||
final String service = "/subscribe";
|
||||
|
||||
//build the uri params
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service);
|
||||
|
||||
HttpEntity<OpenaireSubscription> entity = new HttpEntity<>(obj, httpHeaders);
|
||||
|
||||
//create new template engine
|
||||
RestTemplate template = new RestTemplate();
|
||||
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
||||
ResponseEntity<Subscription> resp;
|
||||
try {
|
||||
//communicate with endpoint
|
||||
resp = restTemplate.exchange(
|
||||
builder.build().encode().toUri(),
|
||||
HttpMethod.POST,
|
||||
entity,
|
||||
new ParameterizedTypeReference<Subscription>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on OpenaireSubscription" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
|
||||
return resp.getBody();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> unsubscribe(String subscriptionId) throws BrokerException {
|
||||
final String service = "/subscriptions/" + subscriptionId;
|
||||
|
||||
//build the uri params
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(apiPath + service);
|
||||
|
||||
try {
|
||||
//communicate with endpoint
|
||||
restTemplate.exchange(
|
||||
builder.build().encode().toUri(),
|
||||
HttpMethod.DELETE,
|
||||
null,
|
||||
new ParameterizedTypeReference<Void>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on unsubscribe" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
return new ResponseEntity<>("OK",HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Subscription getSubscription( String subscriptionId) throws BrokerException {
|
||||
final String service = "/subscriptions/" + subscriptionId;
|
||||
|
||||
//build the uri params
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(apiPath + service);
|
||||
|
||||
ResponseEntity<Subscription> resp;
|
||||
try {
|
||||
//communicate with endpoint
|
||||
resp = restTemplate.exchange(
|
||||
builder.build().encode().toUri(),
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
new ParameterizedTypeReference<Subscription>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on getSubscription" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
return resp.getBody();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Term> getDnetTopics() throws BrokerException {
|
||||
return topics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventsPage getNotificationsBySubscriptionId(String subscriptionId,
|
||||
String page,
|
||||
String size) throws BrokerException {
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(openairePath + "/notifications/")
|
||||
.path("/{id}/{page}/{size}/")
|
||||
.build().expand(subscriptionId,page, size).encode();
|
||||
|
||||
ResponseEntity<EventsPage> resp;
|
||||
try {
|
||||
resp = restTemplate.exchange(
|
||||
uriComponents.toUri(),
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
new ParameterizedTypeReference<EventsPage>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on getNotificationsBySubscriptionId" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
return resp.getBody();
|
||||
}
|
||||
|
||||
//@Override
|
||||
public Map<String, List<Subscription>> getSubscriptionsOfUser(String userEmail)
|
||||
throws BrokerException {
|
||||
|
||||
Map<String, List<SimpleSubscriptionDesc>> simpleSubs = getSimpleSubscriptionsOfUser(userEmail);
|
||||
Map<String,List<Subscription>> subs = new HashMap<>();
|
||||
List<Subscription> subscriptions = null;
|
||||
|
||||
for(String s:simpleSubs.keySet()){
|
||||
List<SimpleSubscriptionDesc> simpleSubscriptionDescs = simpleSubs.get(s);
|
||||
for(SimpleSubscriptionDesc simpleSubscriptionDesc : simpleSubscriptionDescs) {
|
||||
subscriptions = new ArrayList<>();
|
||||
subscriptions.add(getSubscription(simpleSubscriptionDesc.getId()));
|
||||
}
|
||||
subs.put(s,subscriptions);
|
||||
}
|
||||
return subs;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DashboardService {
|
||||
|
||||
List<RepositorySummaryInfo> getRepositoriesSummaryInfo(@PathVariable("userEmail") String userEmail,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException;
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo;
|
||||
import eu.dnetlib.repo.manager.shared.AggregationDetails;
|
||||
import eu.dnetlib.repo.manager.shared.BrokerException;
|
||||
import eu.dnetlib.repo.manager.shared.MetricsInfo;
|
||||
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
|
||||
import eu.dnetlib.repo.manager.shared.broker.BrowseEntry;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import javax.xml.ws.ServiceMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service("dashboardService")
|
||||
public class DashboardServiceImpl implements DashboardService {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(DashboardServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private EmailUtils emailUtils;
|
||||
|
||||
@Autowired
|
||||
private RepositoryService repositoryService;
|
||||
|
||||
@Autowired
|
||||
private BrokerService brokerService;
|
||||
|
||||
@Override
|
||||
public List<RepositorySummaryInfo> getRepositoriesSummaryInfo(String userEmail,
|
||||
String page,
|
||||
String size){
|
||||
|
||||
List<RepositorySummaryInfo> repositorySummaryInfoList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
|
||||
List<Repository> repositoriesOfUser = repositoryService.getRepositoriesOfUser(userEmail, page, size);
|
||||
for(Repository repository: repositoriesOfUser) {
|
||||
|
||||
RepositorySummaryInfo repositorySummaryInfo = new RepositorySummaryInfo();
|
||||
repositorySummaryInfo.setId(repository.getId());
|
||||
repositorySummaryInfo.setRepositoryName(repository.getOfficialName());
|
||||
repositorySummaryInfo.setLogoURL(repository.getLogoUrl());
|
||||
|
||||
//TODO getRepositoryAggregations returns only the 20 more recent items. Is it positive that we will find an indexed version there?
|
||||
long start = System.currentTimeMillis();
|
||||
List<AggregationDetails> aggregationDetailsList = repositoryService.getRepositoryAggregations(repository.getId(),0,20);
|
||||
for(AggregationDetails aggregationDetails: aggregationDetailsList) {
|
||||
if(aggregationDetails.getIndexedVersion()) {
|
||||
repositorySummaryInfo.setRecordsCollected(aggregationDetails.getNumberOfRecords());
|
||||
repositorySummaryInfo.setLastIndexedVersion(aggregationDetails.getDate());
|
||||
break;
|
||||
}
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
System.out.println("Got repo aggregations in "+ (end-start)+"ms");
|
||||
|
||||
try {
|
||||
|
||||
MetricsInfo metricsInfo = repositoryService.getMetricsInfoForRepository(repository.getId());
|
||||
repositorySummaryInfo.setTotalDownloads(metricsInfo.getMetricsNumbers().getTotalDownloads());
|
||||
repositorySummaryInfo.setTotalViews(metricsInfo.getMetricsNumbers().getTotalViews());
|
||||
|
||||
} catch (RepositoryServiceException e) {
|
||||
logger.error("Exception getting metrics info for repository: " + repository.getId(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
List<BrowseEntry> events = brokerService.getTopicsForDatasource(repository.getOfficialName());
|
||||
Long totalEvents = 0L;
|
||||
for(BrowseEntry browseEntry: events)
|
||||
totalEvents += browseEntry.getSize();
|
||||
repositorySummaryInfo.setEnrichmentEvents(totalEvents);
|
||||
|
||||
|
||||
} catch (BrokerException e) {
|
||||
logger.error("Exception getting broker events for repository: " + repository.getId(), e);
|
||||
}
|
||||
|
||||
repositorySummaryInfoList.add(repositorySummaryInfo);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Something baad happened!", e);
|
||||
}
|
||||
|
||||
return repositorySummaryInfoList;
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.security.core.Authentication;
|
||||
|
||||
public interface EmailUtils {
|
||||
|
||||
|
||||
void reportException(Exception exception);
|
||||
|
||||
void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception;
|
||||
|
||||
void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception;
|
||||
|
||||
void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo) throws Exception;
|
||||
|
||||
void sendUserMetricsEnabled(PiwikInfo piwikInfo) throws Exception;
|
||||
|
||||
/****USER REGISTRATION REQUEST EMAILS****/
|
||||
void sendAdminRegistrationEmail(Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
/****SUCCESSFUL REGISTRATION RESULTS EMAILS****/
|
||||
void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
/****FAILURE REGISTRATION RESULTS EMAILS****/
|
||||
void sendUserRegistrationResultsFailureEmail(String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
/****SUCCESSFUL UPDATE RESULTS EMAILS****/
|
||||
void sendUserUpdateResultsSuccessEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
/****FAILURE UPDATE RESULTS EMAILS****/
|
||||
void sendUserUpdateResultsFailureEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
/****VALIDATION OF CONTENT PROVIDER EMAILS****/
|
||||
void sendUserValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
void sendAdminValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
/****GENERAL FAILURE OF VALIDATOR****/
|
||||
void sendAdminGeneralFailure(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
|
||||
void sendAdminUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
void sendUserUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception;
|
||||
|
||||
void sendUponJobCompletion(String repoId,
|
||||
String repoInterfaceId,
|
||||
int scoreUsage,
|
||||
int scoreContent,
|
||||
boolean isSuccess,
|
||||
boolean isUpdate,
|
||||
String issuerEmail,
|
||||
String jobId) throws Exception;
|
||||
}
|
|
@ -1,772 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import eu.dnetlib.repo.manager.config.CascadingPropertyLoader;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
|
||||
import eu.dnetlib.utils.MailLibrary;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.json.JSONException;
|
||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Component("emailUtils")
|
||||
public class EmailUtilsImpl implements EmailUtils {
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(EmailUtilsImpl.class);
|
||||
|
||||
private List<String> specialRecipients = new ArrayList<String>();
|
||||
private boolean override = false, logonly = false;
|
||||
private String overrideEmail = null, from = null;
|
||||
|
||||
@Autowired
|
||||
private MailLibrary mailLibrary;
|
||||
|
||||
@Autowired
|
||||
private CascadingPropertyLoader pLoader;
|
||||
|
||||
@Value("${services.repo-manager.baseUrl}")
|
||||
private String baseUrl;
|
||||
|
||||
@Value("${services.repo-manager.adminEmail}")
|
||||
private String adminEmail;
|
||||
|
||||
@Value("${services.repomanager.usagestats.adminEmail}")
|
||||
private String usageStatsAdminEmail;
|
||||
|
||||
@Value("${services.provide.adminEmail}")
|
||||
private String provideAdminEmail;
|
||||
|
||||
@Value("${validator.results.url}")
|
||||
private String valBaseUrl;
|
||||
|
||||
@Autowired
|
||||
private RepositoryService repositoryService;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init(){
|
||||
System.out.println("url -> " + this.baseUrl);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void reportException(Exception exception) {
|
||||
Writer writer = new StringWriter();
|
||||
PrintWriter printWriter = new PrintWriter(writer);
|
||||
exception.printStackTrace(printWriter);
|
||||
|
||||
List<String> recipients = new ArrayList<String>();
|
||||
|
||||
try {
|
||||
recipients.add(this.adminEmail);
|
||||
String message = "An exception has occurred:\n"+writer.toString();
|
||||
String subject = "Automatic Bug Report";
|
||||
this.sendMail(recipients, subject, message, false, null);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error sending error report", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception {
|
||||
|
||||
try {
|
||||
String subject = "[OpenAIRE-Usage Statistics] New request to enable usage statistics";
|
||||
|
||||
String message = "Dear administrator,\n" +
|
||||
"\n" +
|
||||
"we have received a request to enable the OpenAIRE usage statistics for the following repository \n" +
|
||||
"\n" +
|
||||
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
|
||||
"Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" +
|
||||
"Piwik ID - " + piwikInfo.getSiteId() + "\n" +
|
||||
"Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" +
|
||||
"\n" +
|
||||
"For more information about this request, go here: \n" +
|
||||
this.baseUrl + "/admin/metrics\n" +
|
||||
"\n" +
|
||||
"Best,\n" +
|
||||
"The OpenAIRE team";
|
||||
|
||||
this.sendMail(this.usageStatsAdminEmail, subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending request to enable metrics email to administrator: " + this.usageStatsAdminEmail, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception {
|
||||
|
||||
try {
|
||||
String subject = "[OpenAIRE-Usage Statistics] Your request to enable usage statistics";
|
||||
|
||||
String message = "Dear " + piwikInfo.getRequestorName() + ",\n" +
|
||||
"\n" +
|
||||
"we have received your request to enable the OpenAIRE usage statistics for your repository\n" +
|
||||
"\n" +
|
||||
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
|
||||
"Piwik ID - " + piwikInfo.getSiteId() + "\n" +
|
||||
"Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" +
|
||||
"\n" +
|
||||
"In order to enable the usage statistics, you must install the OpenAIRE's tracking code in your repository software. " +
|
||||
"OpenAIRE's usage statistics service tracking code is maintained on Github as a patch for various versions of DSpace " +
|
||||
"(https://github.com/openaire/OpenAIRE-Piwik-DSpace) and as an Eprints plugin for version 3 " +
|
||||
"(https://github.com/openaire/EPrints-OAPiwik). In case the platform is different from DSpace or EPrints please contact " +
|
||||
"the OpenAIRE team in repositoryusagestats@openaire.eu in order to find a solution.\n" +
|
||||
"\n" +
|
||||
"For more information about your request and configuration details, go here: \n" +
|
||||
this.baseUrl + "/getImpact/instructions/" + piwikInfo.getRepositoryId() + "\n" +
|
||||
"\n" +
|
||||
"Once you have finished configuring your repository or if you have any questions, please notify the OpenAIRE team by sending \n" +
|
||||
"an email to repositoryusagestats@openaire.eu\n" +
|
||||
"\n" +
|
||||
"Best,\n" +
|
||||
"The OpenAIRE team";
|
||||
|
||||
this.sendMail(piwikInfo.getRequestorEmail(), subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending request to enable metrics email to user: " + piwikInfo.getRequestorEmail(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo) throws Exception {
|
||||
|
||||
try {
|
||||
String subject = "[OpenAIRE-Usage Statistics] Usage statistics have been enabled";
|
||||
|
||||
String message = "Dear administrator,\n" +
|
||||
"\n" +
|
||||
"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" +
|
||||
"\n" +
|
||||
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
|
||||
"Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" +
|
||||
"Piwik ID - " + piwikInfo.getSiteId() + "\n" +
|
||||
"Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" +
|
||||
"\n" +
|
||||
"Best,\n" +
|
||||
"The OpenAIRE team";
|
||||
|
||||
this.sendMail(this.usageStatsAdminEmail, subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending metrics enabled notification email to administator: " + this.usageStatsAdminEmail, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUserMetricsEnabled(PiwikInfo piwikInfo) throws Exception {
|
||||
|
||||
try {
|
||||
String subject = "[OpenAIRE-Usage Statistics] Usage statistics have been enabled";
|
||||
|
||||
String message = "Dear " + piwikInfo.getRequestorName() + ",\n" +
|
||||
"\n" +
|
||||
"The installation and configuration of OpenAIRE's tracking code for your repository \"" + piwikInfo.getRepositoryName() +
|
||||
"\" has been completed and validated and the usage statistics have been enabled in OpenAIRE.\n" +
|
||||
"\n" +
|
||||
"You can preview the statistics in your repository's dashboard: \n" +
|
||||
this.baseUrl + "/getImpact/" + piwikInfo.getRepositoryId() + "\n" +
|
||||
"\n" +
|
||||
" For more information and questions, you can contact the openaire support team by sending an email to " +
|
||||
"repositoryusagestats@openaire.eu\n" +
|
||||
"\n" +
|
||||
"Best,\n" +
|
||||
"The OpenAIRE team";
|
||||
|
||||
this.sendMail(piwikInfo.getRequestorEmail(), subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending metrics enabled notification email to user: " + piwikInfo.getRequestorEmail(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendAdminRegistrationEmail(Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider registration request started for " +
|
||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||
|
||||
String message = "Dear administrator" + ",\n" +
|
||||
"\n" +
|
||||
"We received a request to register the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]" +
|
||||
" to the OpenAIRE compliant list of content providers. " +
|
||||
"A validation process against the OpenAIRE guidelines compatibility " +
|
||||
"has been started. You will be informed in another message once the process is finished." +
|
||||
"\n\n" +
|
||||
"Please do not reply to this message\n" +
|
||||
"This message has been generated automatically.\n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(this.provideAdminEmail, subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to the administrator", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider registration request started for " +
|
||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||
|
||||
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||
String message = "Dear "+SecurityContextHolder.getContext().getAuthentication().getName()+",\n" +
|
||||
"\n" +
|
||||
"We received a request to register the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]" +
|
||||
" to the OpenAIRE compliant list of content providers. " +
|
||||
"A validation process against the OpenAIRE guidelines compatibility " +
|
||||
"has been started. You will be informed in another message once the process is finished." +
|
||||
"\n\n" +
|
||||
"Please do not reply to this message\n" +
|
||||
"This message has been generated automatically.\n\n" +
|
||||
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(repository.getRegisteredBy(), subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider registration request - results (success) for " +
|
||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||
|
||||
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||
String message = "Dear user,\n" +
|
||||
"\n" +
|
||||
"the compatibility test on " + "[" + repository.getEnglishName() + "]" +
|
||||
" was successful and the datasource type \""+ repository.getDatasourceType() + "\" will be prepared for aggregation in OpenAIRE."+
|
||||
"\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()+
|
||||
"\nOfficial Name:" + repository.getOfficialName() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
|
||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
|
||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||
"\n\n\nPlease do not reply to this email\n"+
|
||||
"This message has been generated manually\n\n"+
|
||||
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(repository.getRegisteredBy(), subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider registration request - results (success) for " +
|
||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||
|
||||
String message = "Dear admin ,\n" +
|
||||
"\n" +
|
||||
"the compatibility test on " + "[" + repository.getEnglishName() + "]" +
|
||||
" was successful and the datasource type \""+ repository.getDatasourceType() + "\" will be prepared for aggregation in OpenAIRE."+
|
||||
"\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()+
|
||||
"\nOfficial Name:" + repository.getOfficialName() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
|
||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
|
||||
"\n\nUser Contact:"+ issuerEmail +""+
|
||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||
"\n\n\nPlease do not reply to this email\n"+
|
||||
"This message has been generated manually\n\n"+
|
||||
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(this.provideAdminEmail, subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider registration request - results (failure) for " +
|
||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||
String message = "Dear user,\n" +
|
||||
"\n" +
|
||||
"the compatibility test on " + "[" + repository.getEnglishName() + "]" +
|
||||
" was not successful and the registration process was interrupted."+
|
||||
"\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()+
|
||||
"\nOfficial Name:" + repository.getOfficialName() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
|
||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
|
||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||
"\n\n\nPlease do not reply to this email\n"+
|
||||
"This message has been generated manually\n\n"+
|
||||
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(repository.getRegisteredBy(), subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider registration request - results (failure) for " +
|
||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||
|
||||
String message = "Dear admin,\n" +
|
||||
"\n" +
|
||||
"the compatibility test on " + "[" + repository.getEnglishName() + "]" +
|
||||
" was not successful and the registration process was interrupted."+
|
||||
"\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()+
|
||||
"\nOfficial Name:" + repository.getOfficialName() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
|
||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
|
||||
"\n\nUser Contact:"+ issuerEmail +""+
|
||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||
"\n\n\nPlease do not reply to this email\n"+
|
||||
"This message has been generated manually\n\n"+
|
||||
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(this.provideAdminEmail, subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUserUpdateResultsSuccessEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider registration request - results (success) for " +
|
||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||
|
||||
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||
String message = "Dear user,\n" +
|
||||
"\n" +
|
||||
"the compatibility test on [" + repository.getEnglishName()+"] 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" +
|
||||
"Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
|
||||
"\nOfficial Name:" + repository.getOfficialName() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
|
||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
|
||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||
"\n\n\nPlease do not reply to this email\n"+
|
||||
"This message has been generated manually\n\n"+
|
||||
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(issuer, subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to the administrator", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider registration request - results (success) for " +
|
||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||
|
||||
String message = "Dear admin,\n" +
|
||||
"\n" +
|
||||
"the compatibility test on [" + repository.getEnglishName()+"] 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" +
|
||||
"Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
|
||||
"\nOfficial Name:" + repository.getOfficialName() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
|
||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
|
||||
"\n\nUser Contact:"+ issuerEmail +""+
|
||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||
"\n\n\nPlease do not reply to this email\n"+
|
||||
"This message has been generated manually\n\n"+
|
||||
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(this.provideAdminEmail, subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to the administrator", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUserUpdateResultsFailureEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider update request - results (failure) for " +
|
||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||
|
||||
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||
String message = "Dear user,\n" +
|
||||
"\n" +
|
||||
"the compatibility test on " + "[" + repository.getEnglishName() + "]" +
|
||||
" was not successful."+
|
||||
"\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()+
|
||||
"\nOfficial Name:" + repository.getOfficialName() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
|
||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
|
||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||
"\n\n\nPlease do not reply to this email\n"+
|
||||
"This message has been generated manually\n\n"+
|
||||
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(issuer, subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider update request - results (failure) for " +
|
||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||
|
||||
String message = "Dear admin,\n" +
|
||||
"\n" +
|
||||
"the compatibility test on " + "[" + repository.getEnglishName() + "]" +
|
||||
" was not successful."+
|
||||
"\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()+
|
||||
"\nOfficial Name:" + repository.getOfficialName() +
|
||||
"\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
|
||||
"\n\nValidation Set: " + repositoryInterface.getAccessSet() +
|
||||
"\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
|
||||
"\n\nUser Contact:"+ issuerEmail +""+
|
||||
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
|
||||
"\n\n\nPlease do not reply to this email\n"+
|
||||
"This message has been generated manually\n\n"+
|
||||
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(this.provideAdminEmail, subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUserValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE validator - Test results ";
|
||||
|
||||
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||
String message = "Dear user,\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" +
|
||||
"This message has been generated automatically.\n" +
|
||||
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(issuer, subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending validation submission notification email to user: " + issuer, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendAdminValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE validator - Test results ";
|
||||
|
||||
String message = "Dear admin,\n" +
|
||||
"\n" +
|
||||
"the validation request you have submitted has finished. You can retrieve the results by following this url: "+ valBaseUrl+"" + jobId+" .\n\n" +
|
||||
"\n\nUser Contact:"+ issuer +""+
|
||||
"Please do not reply to this message.\n" +
|
||||
"This message has been generated automatically.\n" +
|
||||
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(this.provideAdminEmail, subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending validation submission notification email to user: " + issuer, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendAdminGeneralFailure(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE validator - job failure";
|
||||
|
||||
String message = "Dear admin,\n" +
|
||||
"\n" +
|
||||
"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.\n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(this.provideAdminEmail, subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending validation submission notification email to user: " + issuer, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendAdminUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider update request started for " +
|
||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||
|
||||
String message = "Dear administrator" + ",\n" +
|
||||
"\n" +
|
||||
"We received a request to update the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]." +
|
||||
"A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" +
|
||||
"Please do not reply to this message\n" +
|
||||
"This message has been generated automatically.\n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(this.provideAdminEmail, subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to the administrator", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUserUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE content provider update request started for " +
|
||||
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
|
||||
|
||||
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||
String message = "Dear user,\n" +
|
||||
"\n" +
|
||||
"We received a request to update the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]." +
|
||||
"A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" +
|
||||
"Please do not reply to this message\n" +
|
||||
"This message has been generated automatically.\n\n" +
|
||||
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(repository.getRegisteredBy(), subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception {
|
||||
try {
|
||||
String subject = "OpenAIRE validator - Test submission ";
|
||||
|
||||
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
|
||||
String message = "Dear user,\n" +
|
||||
"\n" +
|
||||
"The validation request you have submitted has started.\n" +
|
||||
"Please do not reply to this message.\n" +
|
||||
"This message has been generated automatically.\n" +
|
||||
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
|
||||
"Regards,\n" +
|
||||
"the OpenAIRE technical team\n";
|
||||
|
||||
this.sendMail(jobForValidation.getUserEmail(), subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending validation submission notification email to user: " + jobForValidation.getUserEmail(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUponJobCompletion(
|
||||
String repoId,
|
||||
String repoInterfaceId,
|
||||
int scoreUsage,
|
||||
int scoreContent,
|
||||
boolean isSuccess,
|
||||
boolean isUpdate,
|
||||
String issuerEmail,
|
||||
String jobId) throws Exception {
|
||||
List<RepositoryInterface> repositoryInterfaces = repositoryService.getRepositoryInterface(repoId);
|
||||
if(repositoryInterfaces.size()==0)
|
||||
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);
|
||||
Repository repository = repositoryService.getRepositoryById(repoId);
|
||||
|
||||
if(!isUpdate){
|
||||
if(isSuccess){
|
||||
if(scoreContent>=50 && scoreUsage >= 50){
|
||||
this.sendUserRegistrationResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
|
||||
this.sendAdminRegistrationResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication());
|
||||
}else{
|
||||
this.sendUserRegistrationResultsFailureEmail(jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
|
||||
this.sendAdminRegistrationResultsFailureEmail(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication());
|
||||
}
|
||||
}else{
|
||||
this.sendAdminGeneralFailure(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication());
|
||||
}
|
||||
}else{
|
||||
if(isSuccess){
|
||||
if(scoreContent>=50 && scoreUsage >= 50){
|
||||
this.sendUserUpdateResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
|
||||
this.sendAdminUpdateResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
|
||||
}else{
|
||||
this.sendUserUpdateResultsFailureEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
|
||||
this.sendAdminUpdateResultsFailureEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
|
||||
}
|
||||
}else{
|
||||
this.sendAdminGeneralFailure(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void sendMail(String email, String subject, String message, boolean sendToSpecial, List<String> repoAdminMails) throws Exception {
|
||||
ArrayList<String> to = new ArrayList<String>();
|
||||
to.add(email);
|
||||
this.sendMail(to,subject,message,sendToSpecial,repoAdminMails);
|
||||
}
|
||||
|
||||
public void sendMail(List<String> recipients, String subject, String message, boolean sendToSpecial, List<String> repoAdminMails) throws Exception {
|
||||
|
||||
try {
|
||||
if (sendToSpecial) {
|
||||
recipients.addAll(this.specialRecipients);
|
||||
}
|
||||
|
||||
if (repoAdminMails != null)
|
||||
recipients.addAll(repoAdminMails);
|
||||
|
||||
if (this.override) {
|
||||
recipients.clear();
|
||||
recipients.add(overrideEmail);
|
||||
}
|
||||
if (!logonly)
|
||||
mailLibrary.sendEmail(recipients.toArray(new String[]{}), subject, message);
|
||||
LOGGER.debug("Sending mail to Recipients: " + recipients + " Subject: " + subject + " Message: " + message);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error sending mail to Recipients: " + recipients + " Subject: " + subject + " Message: " + message, e);
|
||||
throw new Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String getEmailProperty(String key) {
|
||||
return pLoader.getProperties().getProperty(key);
|
||||
}
|
||||
|
||||
public void setSpecialRecipients(String specialRecipients) {
|
||||
String[] recps = specialRecipients.split(",");
|
||||
|
||||
for (String recp : recps) {
|
||||
recp = recp.trim();
|
||||
|
||||
this.specialRecipients.add(recp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setOverride(boolean override) {
|
||||
this.override = override;
|
||||
}
|
||||
|
||||
public void setOverrideEmail(String overrideEmail) {
|
||||
this.overrideEmail = overrideEmail;
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public boolean isLogonly() {
|
||||
return logonly;
|
||||
}
|
||||
|
||||
public void setLogonly(boolean logonly) {
|
||||
this.logonly = logonly;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import eu.dnetlib.repo.manager.shared.JobsOfUser;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
public interface MonitorService {
|
||||
|
||||
|
||||
JobsOfUser getJobsOfUser(String user,
|
||||
String jobType,
|
||||
String offset,
|
||||
String limit,
|
||||
String dateFrom,
|
||||
String dateTo,
|
||||
String validationStatus,
|
||||
String includeJobsTotal) throws JSONException, ValidatorServiceException;
|
||||
|
||||
int getJobsOfUserPerValidationStatus(String user,
|
||||
String jobType,
|
||||
String validationStatus) throws JSONException;
|
||||
|
||||
|
||||
StoredJob getJobSummary(String jobId,
|
||||
String groupBy) throws JSONException;
|
||||
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorService;
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import eu.dnetlib.repo.manager.shared.Constants;
|
||||
import eu.dnetlib.repo.manager.shared.JobsOfUser;
|
||||
import gr.uoa.di.driver.util.ServiceLocator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service("monitorService")
|
||||
public class MonitorServiceImpl implements MonitorService {
|
||||
|
||||
@Resource(name = "validatorServiceLocator")
|
||||
private ServiceLocator<ValidatorService> validatorServiceLocator;
|
||||
|
||||
private ValidatorService getValidationService() {
|
||||
return this.validatorServiceLocator.getService();
|
||||
}
|
||||
|
||||
public ServiceLocator<ValidatorService> getValidatorServiceLocator() {
|
||||
return validatorServiceLocator;
|
||||
}
|
||||
|
||||
public void setValidatorServiceLocator(ServiceLocator<ValidatorService> validatorServiceLocator) {
|
||||
this.validatorServiceLocator = validatorServiceLocator;
|
||||
}
|
||||
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(MonitorServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public JobsOfUser getJobsOfUser(String user,
|
||||
String jobType,
|
||||
String offset,
|
||||
String limit,
|
||||
String dateFrom,
|
||||
String dateTo,
|
||||
String validationStatus,
|
||||
String includeJobsTotal) throws JSONException, ValidatorServiceException {
|
||||
|
||||
LOGGER.debug("Getting jobs of user : " + user);
|
||||
LOGGER.debug(user + "/" + jobType + "/" + offset + "/" + dateFrom + "/" + dateTo + "/" + validationStatus + "/" + includeJobsTotal);
|
||||
JobsOfUser retJobs = new JobsOfUser();
|
||||
retJobs.setJobs(getValidationService().getStoredJobsNew(user, jobType, Integer.parseInt(offset),
|
||||
Integer.parseInt(limit), dateFrom, dateTo, validationStatus));
|
||||
if (Boolean.parseBoolean(includeJobsTotal)) {
|
||||
retJobs.setTotalJobs(this.getJobsTotalNumberOfUser(user, jobType, null));
|
||||
retJobs.setTotalJobsSuccessful(this.getJobsTotalNumberOfUser(user, jobType, Constants.VALIDATION_JOB_STATUS_SUCCESSFUL));
|
||||
retJobs.setTotalJobsFailed(this.getJobsTotalNumberOfUser(user, jobType, Constants.VALIDATION_JOB_STATUS_FAILED));
|
||||
retJobs.setTotalJobsOngoing(this.getJobsTotalNumberOfUser(user, jobType,Constants.VALIDATION_JOB_STATUS_ONGOING));
|
||||
}
|
||||
|
||||
//TODO fix status with new validator version
|
||||
if(retJobs.getJobs() != null){
|
||||
for(StoredJob job :retJobs.getJobs()){
|
||||
if (job.getContentJobStatus().equals("ongoing") || job.getUsageJobStatus().equals("ongoing")) {
|
||||
job.setValidationStatus("ongoing");
|
||||
} else if ((job.getValidationType().equals("CU") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("finished") && job.getContentJobScore() > 50 && job.getUsageJobScore() > 50)
|
||||
|| (job.getValidationType().equals("C") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("none") && job.getContentJobScore() > 50)
|
||||
|| (job.getValidationType().equals("U") && job.getContentJobStatus().equals("none") && job.getUsageJobStatus().equals("finished") && job.getUsageJobScore() > 50)) {
|
||||
job.setValidationStatus("successful");
|
||||
} else if ((job.getValidationType().equals("CU") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("finished") && (job.getContentJobScore() <= 50 || job.getUsageJobScore() <= 50))
|
||||
|| (job.getValidationType().equals("C") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("none") && job.getContentJobScore() <= 50)
|
||||
|| (job.getValidationType().equals("U") && job.getContentJobStatus().equals("none") && job.getUsageJobStatus().equals("finished") && job.getUsageJobScore() <= 50) ) {
|
||||
job.setValidationStatus("failed");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return retJobs;
|
||||
|
||||
}
|
||||
|
||||
private int getJobsTotalNumberOfUser(String user, String jobType, String validationStatus) throws ValidatorServiceException {
|
||||
return getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getJobsOfUserPerValidationStatus(String user,
|
||||
String jobType,
|
||||
String validationStatus) throws JSONException {
|
||||
LOGGER.debug("Getting job with validation status : " + validationStatus);
|
||||
try {
|
||||
return getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus);
|
||||
} catch (ValidatorServiceException e) {
|
||||
LOGGER.error(e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoredJob getJobSummary(String jobId,
|
||||
String groupBy) throws JSONException {
|
||||
LOGGER.debug("Getting job summary with id : " + jobId);
|
||||
try {
|
||||
return getValidationService().getStoredJob(Integer.parseInt(jobId), groupBy);
|
||||
} catch (ValidatorServiceException e) {
|
||||
LOGGER.error(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.repo.manager.domain.OrderByField;
|
||||
import eu.dnetlib.repo.manager.domain.OrderByType;
|
||||
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface PiWikService {
|
||||
|
||||
PiwikInfo getPiwikSiteForRepo(String repositoryId);
|
||||
|
||||
PiwikInfo savePiwikInfo(PiwikInfo piwikInfo);
|
||||
|
||||
List<PiwikInfo> getPiwikSitesForRepos(OrderByField orderByField, OrderByType orderByType, int from, int quantity, String searchField);
|
||||
|
||||
int getPiwikSitesTotals(String searchField);
|
||||
|
||||
ResponseEntity<Object> approvePiwikSite(String repositoryId);
|
||||
|
||||
String getOpenaireId(String repositoryid);
|
||||
|
||||
ResponseEntity<Object> markPiwikSiteAsValidated(String repositoryId) throws RepositoryServiceException;
|
||||
|
||||
PiwikInfo enableMetricsForRepository(String officialName, String repoWebsite, PiwikInfo piwikInfo) throws RepositoryServiceException;
|
||||
}
|
|
@ -1,232 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.repo.manager.domain.OrderByField;
|
||||
import eu.dnetlib.repo.manager.domain.OrderByType;
|
||||
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.PreparedStatementSetter;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service("piwikService")
|
||||
public class PiWikServiceImpl implements PiWikService {
|
||||
|
||||
@Qualifier("repomanager.dataSource")
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
|
||||
@Value("${services.repomanager.analyticsURL}")
|
||||
private String analyticsURL;
|
||||
|
||||
|
||||
@Autowired
|
||||
private RepositoryService repositoryService;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("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 final static 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 final static String GET_PIWIK_SITES_TOTAL = "select count(*) as totals from piwik_site ";
|
||||
|
||||
private final static String APPROVE_PIWIK_SITE = "update piwik_site set validated=true, validationdate=now() where repositoryid = ?;";
|
||||
|
||||
private 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.getBoolean("validated"), rs.getTimestamp("validationdate"), rs.getString("comment"));
|
||||
|
||||
|
||||
@Override
|
||||
public PiwikInfo getPiwikSiteForRepo(String repositoryId) {
|
||||
try{
|
||||
return new JdbcTemplate(dataSource).queryForObject(GET_PIWIK_SITE, new String[]{repositoryId}, new int[]{Types.VARCHAR}, piwikRowMapper);
|
||||
}catch (EmptyResultDataAccessException e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or (hasRole('ROLE_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)")
|
||||
public PiwikInfo savePiwikInfo(PiwikInfo piwikInfo) {
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
jdbcTemplate.update(INSERT_PIWIK_INFO, new Object[]{piwikInfo.getRepositoryId(), piwikInfo.getSiteId(), piwikInfo.getRequestorName(),
|
||||
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});
|
||||
return piwikInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PiwikInfo> getPiwikSitesForRepos(OrderByField orderByField, OrderByType orderByType, int from, int quantity, String searchField) {
|
||||
try{
|
||||
String finalizedQuery = GET_PIWIK_SITES + " where ("+
|
||||
" repositoryid ilike ? " +
|
||||
" or siteid ilike ?" +
|
||||
" or requestorname ilike ?" +
|
||||
" or requestoremail ilike ?" +
|
||||
" or comment ilike ?" +
|
||||
" or repositoryname ilike ?"+
|
||||
" or country ilike ?"
|
||||
+") order by "+orderByField + " " + orderByType + " offset ? limit ?";
|
||||
|
||||
return new JdbcTemplate(dataSource).query(finalizedQuery, preparedStatement -> {
|
||||
preparedStatement.setString(1,"%"+searchField+"%");
|
||||
preparedStatement.setString(2,"%"+searchField+"%");
|
||||
preparedStatement.setString(3,"%"+searchField+"%");
|
||||
preparedStatement.setString(4,"%"+searchField+"%");
|
||||
preparedStatement.setString(5,"%"+searchField+"%");
|
||||
preparedStatement.setString(6,"%"+searchField+"%");
|
||||
preparedStatement.setString(7,"%"+searchField+"%");
|
||||
preparedStatement.setInt(8,from);
|
||||
preparedStatement.setInt(9,quantity);
|
||||
}, piwikRowMapper);
|
||||
}catch (EmptyResultDataAccessException e){
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPiwikSitesTotals(String searchField){
|
||||
try{
|
||||
String finalizedQuery = GET_PIWIK_SITES_TOTAL + " where ("+
|
||||
" repositoryid ilike ? " +
|
||||
" or siteid ilike ?" +
|
||||
" or requestorname ilike ?" +
|
||||
" or requestoremail ilike ?" +
|
||||
" or comment ilike ?" +
|
||||
" or repositoryname ilike ?"+
|
||||
" or country ilike ?)";
|
||||
|
||||
return new JdbcTemplate(dataSource).query(finalizedQuery, preparedStatement -> {
|
||||
preparedStatement.setString(1,"%"+searchField+"%");
|
||||
preparedStatement.setString(2,"%"+searchField+"%");
|
||||
preparedStatement.setString(3,"%"+searchField+"%");
|
||||
preparedStatement.setString(4,"%"+searchField+"%");
|
||||
preparedStatement.setString(5,"%"+searchField+"%");
|
||||
preparedStatement.setString(6,"%"+searchField+"%");
|
||||
preparedStatement.setString(7,"%"+searchField+"%");
|
||||
},rowMapper -> {
|
||||
rowMapper.next();
|
||||
return rowMapper.getInt("totals");
|
||||
});
|
||||
}catch (EmptyResultDataAccessException e){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
|
||||
public ResponseEntity<Object> approvePiwikSite(String repositoryId) {
|
||||
new JdbcTemplate(dataSource).update(APPROVE_PIWIK_SITE, new Object[] {repositoryId}, new int[] {Types.VARCHAR});
|
||||
return new ResponseEntity<>("OK",HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOpenaireId(String repositoryId) {
|
||||
if (repositoryId != null && repositoryId.contains("::"))
|
||||
return repositoryId.split("::")[0] + "::" + DigestUtils.md5Hex(repositoryId.split("::")[1]);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
|
||||
public ResponseEntity<Object> markPiwikSiteAsValidated(String repositoryId) throws RepositoryServiceException {
|
||||
try {
|
||||
approvePiwikSite(repositoryId);
|
||||
|
||||
PiwikInfo piwikInfo = getPiwikSiteForRepo(repositoryId);
|
||||
emailUtils.sendAdministratorMetricsEnabled(piwikInfo);
|
||||
emailUtils.sendUserMetricsEnabled(piwikInfo);
|
||||
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
LOGGER.error("Error while approving piwik site: ", e);
|
||||
emailUtils.reportException(e);
|
||||
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending email to administrator or user about the enabling of metrics", e);
|
||||
emailUtils.reportException(e);
|
||||
}
|
||||
return new ResponseEntity<>("OK",HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or (hasRole('ROLE_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)")
|
||||
public PiwikInfo enableMetricsForRepository(String officialName,
|
||||
String repoWebsite,
|
||||
PiwikInfo piwikInfo) throws RepositoryServiceException {
|
||||
try {
|
||||
String URL = analyticsURL + "siteName=" + URLEncoder.encode(officialName, "UTF-8") + "&url="
|
||||
+ URLEncoder.encode(repoWebsite, "UTF-8");
|
||||
Map map = new ObjectMapper().readValue(new URL(URL), Map.class);
|
||||
String siteId = null;
|
||||
if(map.get("value")!=null) {
|
||||
siteId = map.get("value").toString();
|
||||
}
|
||||
piwikInfo.setSiteId(siteId);
|
||||
|
||||
savePiwikInfo(piwikInfo);
|
||||
|
||||
Repository repository = repositoryService.getRepositoryById(piwikInfo.getRepositoryId());
|
||||
repository.setPiwikInfo(piwikInfo);
|
||||
|
||||
repositoryService.updateRepository(repository, SecurityContextHolder.getContext().getAuthentication());
|
||||
|
||||
emailUtils.sendAdministratorRequestToEnableMetrics(piwikInfo);
|
||||
emailUtils.sendUserRequestToEnableMetrics(piwikInfo);
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
LOGGER.error("Error while creating piwikScript URL", uee);
|
||||
emailUtils.reportException(uee);
|
||||
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
} catch (IOException ioe) {
|
||||
LOGGER.error("Error while creating piwik site", ioe);
|
||||
emailUtils.reportException(ioe);
|
||||
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending email to administrator or user about the request to enable metrics", e);
|
||||
emailUtils.reportException(e);
|
||||
}
|
||||
return piwikInfo;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.shared.*;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface RepositoryService {
|
||||
|
||||
|
||||
Country[] getCountries() ;
|
||||
|
||||
List<RepositorySnippet> getRepositoriesByCountry(String country, String mode, Boolean managed) throws JSONException, IOException;
|
||||
|
||||
List<Repository> getRepositoriesOfUser(String userEmail,
|
||||
String page,
|
||||
String size) throws JSONException;
|
||||
|
||||
Repository getRepositoryById(String id) throws JSONException, ResourceNotFoundException;
|
||||
|
||||
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,
|
||||
String page,
|
||||
String size) throws JSONException;
|
||||
|
||||
List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName,
|
||||
String officialName, String requestSortBy, String order,
|
||||
int page, int pageSize) throws Exception;
|
||||
|
||||
List<RepositoryInterface> getRepositoryInterface(String id) throws JSONException;
|
||||
|
||||
Repository addRepository(String datatype, Repository repository) throws Exception;
|
||||
|
||||
void deleteRepositoryInterface(String id, String registeredBy);
|
||||
|
||||
RepositoryInterface addRepositoryInterface(String datatype,
|
||||
String repoId,
|
||||
String registeredBy,
|
||||
RepositoryInterface iFace) throws JSONException, ResourceNotFoundException, ValidatorServiceException;
|
||||
|
||||
List<String> getDnetCountries();
|
||||
|
||||
List<String> getTypologies();
|
||||
|
||||
List<Timezone> getTimezones();
|
||||
|
||||
Repository updateRepository(Repository repository, Authentication authentication) throws Exception;
|
||||
|
||||
List<String> getUrlsOfUserRepos(String user_email,
|
||||
String page,
|
||||
String size) throws JSONException;
|
||||
|
||||
List<String> getDatasourceVocabularies(String mode);
|
||||
|
||||
Map<String, String> getCompatibilityClasses(String mode);
|
||||
|
||||
Map<String, String> getDatasourceClasses(String mode);
|
||||
|
||||
String getCountryName(String countryCode);
|
||||
|
||||
MetricsInfo getMetricsInfoForRepository(String repoId) throws RepositoryServiceException;
|
||||
|
||||
Map<String, String> getListLatestUpdate(String mode) throws RepositoryServiceException, JSONException;
|
||||
|
||||
RepositoryInterface updateRepositoryInterface(String repositoryId, String registeredBy, RepositoryInterface repositoryInterface) throws Exception;
|
||||
|
||||
}
|
|
@ -1,901 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.domain.enabling.Vocabulary;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
|
||||
import eu.dnetlib.repo.manager.domain.RequestFilter;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.shared.*;
|
||||
import eu.dnetlib.repo.manager.utils.Converter;
|
||||
import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader;
|
||||
import gr.uoa.di.driver.xml.repository.INTERFACE;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service("repositoryService")
|
||||
public class RepositoryServiceImpl implements RepositoryService {
|
||||
|
||||
@Value("${api.baseAddress}")
|
||||
private String baseAddress;
|
||||
|
||||
@Value("${services.repo-manager.adminEmail}")
|
||||
private String adminEmail;
|
||||
|
||||
@Autowired
|
||||
RestTemplate restTemplate;
|
||||
|
||||
private HttpHeaders httpHeaders;
|
||||
|
||||
private final String[] vocabularyNames = {"dnet:countries", "dnet:datasource_typologies", "dnet:compatibilityLevel"};
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(RepositoryServiceImpl.class);
|
||||
|
||||
@Value("${services.repomanager.usageStatisticsDiagramsBaseURL}")
|
||||
private String usageStatisticsDiagramsBaseURL;
|
||||
|
||||
@Value("${services.repomanager.usageStatisticsNumbersBaseURL}")
|
||||
private String usageStatisticsNumbersBaseURL;
|
||||
|
||||
@Autowired
|
||||
private VocabularyLoader vocabularyLoader;
|
||||
|
||||
@Autowired
|
||||
private PiWikService piWikService;
|
||||
|
||||
@Autowired
|
||||
private EmailUtils emailUtils;
|
||||
|
||||
@Autowired
|
||||
ValidatorService validatorService;
|
||||
|
||||
|
||||
private Map<String, Vocabulary> vocabularyMap = new ConcurrentHashMap<>();
|
||||
|
||||
private Map<String, String> countriesMap = new HashMap<>();
|
||||
private Map<String, String> inverseCountriesMap = new HashMap<>();
|
||||
|
||||
private static Map<String,List<String>> dataSourceClass = new HashMap<>();
|
||||
|
||||
private static Map<String,String> invertedDataSourceClass = new HashMap<>();
|
||||
|
||||
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
LOGGER.debug("Initialization method of repository api!");
|
||||
LOGGER.debug("Updated version!");
|
||||
|
||||
dataSourceClass.put("opendoar",Arrays.asList("pubsrepository::institutional","pubsrepository::thematic","pubsrepository::unknown","pubsrepository::mock"));
|
||||
dataSourceClass.put("re3data", Collections.singletonList("datarepository::unknown"));
|
||||
dataSourceClass.put("journal", Collections.singletonList("pubsrepository::journal"));
|
||||
dataSourceClass.put("aggregator",Arrays.asList("aggregator::pubsrepository::institutional","aggregator::pubsrepository::journals","aggregator::datarepository", "aggregator::pubsrepository::unknown"));
|
||||
|
||||
invertedDataSourceClass.put("pubsrepository::institutional","opendoar");
|
||||
invertedDataSourceClass.put("pubsrepository::thematic","opendoar");
|
||||
invertedDataSourceClass.put("pubsrepository::unknown","opendoar");
|
||||
invertedDataSourceClass.put("pubsrepository::mock","opendoar");
|
||||
invertedDataSourceClass.put("datarepository::unknown","re3data");
|
||||
invertedDataSourceClass.put("pubsrepository::journal","journal");
|
||||
invertedDataSourceClass.put("aggregator::pubsrepository::institutional","aggregator");
|
||||
invertedDataSourceClass.put("aggregator::pubsrepository::journals","aggregator");
|
||||
invertedDataSourceClass.put("aggregator::datarepository","aggregator");
|
||||
invertedDataSourceClass.put("aggregator::pubsrepository::unknown","aggregator");
|
||||
|
||||
|
||||
httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
||||
|
||||
for (String vocName : vocabularyNames) {
|
||||
vocabularyMap.put(vocName, vocabularyLoader.getVocabulary(vocName, Locale.ENGLISH, Locale.ROOT));
|
||||
}
|
||||
|
||||
Country[] countries = getCountries();
|
||||
for (Country c : countries) {
|
||||
countriesMap.put(c.getName(), c.getCode());
|
||||
inverseCountriesMap.put(c.getCode(), c.getName());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Country[] getCountries() {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/countries")
|
||||
.build().encode();
|
||||
return restTemplate.getForObject(uriComponents.toUri(), Country[].class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<RepositorySnippet> getRepositoriesByCountry(String country,
|
||||
String mode,
|
||||
Boolean managed) throws JSONException, IOException {
|
||||
|
||||
LOGGER.debug("Getting repositories by country!");
|
||||
int page = 0;
|
||||
int size = 100;
|
||||
List<RepositorySnippet> resultSet = new ArrayList<>();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
String filterKey = "UNKNOWN";
|
||||
if (mode.equalsIgnoreCase("opendoar"))
|
||||
filterKey = "openaire____::opendoar";
|
||||
else if (mode.equalsIgnoreCase("re3data"))
|
||||
filterKey = "openaire____::re3data";
|
||||
|
||||
|
||||
LOGGER.debug("Country code equals : " + country);
|
||||
LOGGER.debug("Filter mode equals : " + filterKey);
|
||||
|
||||
UriComponents uriComponents = searchSnipperDatasource(String.valueOf(page),String.valueOf(size));
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setCountry(country);
|
||||
requestFilter.setCollectedfrom(filterKey);
|
||||
|
||||
try{
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
||||
while (jsonArray.length() > 0 ) {
|
||||
resultSet.addAll(mapper.readValue(String.valueOf(jsonArray),
|
||||
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;
|
||||
}catch (Exception e){
|
||||
LOGGER.debug("Exception on getRepositoriesByCountry" , e);
|
||||
// emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName,
|
||||
String officialName, String requestSortBy, String order, int page, int pageSize) throws Exception {
|
||||
|
||||
LOGGER.debug("Searching registered repositories");
|
||||
|
||||
List<RepositorySnippet> resultSet = new ArrayList<>();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
UriComponents uriComponents = searchRegisteredDatasource(requestSortBy, order, Integer.toString(page), Integer.toString(pageSize));
|
||||
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setCountry(country);
|
||||
requestFilter.setTypology(typology);
|
||||
requestFilter.setOfficialname(officialName);
|
||||
requestFilter.setEnglishname(englishName);
|
||||
|
||||
try {
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
||||
|
||||
resultSet.addAll(mapper.readValue(String.valueOf(jsonArray), mapper.getTypeFactory().constructCollectionType(List.class, RepositorySnippet.class)));
|
||||
|
||||
return resultSet;
|
||||
}catch (Exception e){
|
||||
LOGGER.error("Error searching registered datasources" , e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private Repository updateRepositoryInfo(Repository r) throws JSONException {
|
||||
|
||||
/*
|
||||
* from datasource class
|
||||
* we get the datasource type form the inverted map
|
||||
* */
|
||||
r.setDatasourceType(getRepositoryType(r.getDatasourceClass()));
|
||||
r.setInterfaces(this.getRepositoryInterface(r.getId()));
|
||||
r.setPiwikInfo(piWikService.getPiwikSiteForRepo(r.getId()));
|
||||
r.setCountryName(getCountryName(r.getCountryCode()));
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
private Collection<Repository> getRepositoriesByMode(String mode, List<Repository> rs) {
|
||||
|
||||
List<Repository> reps = new ArrayList<>();
|
||||
for (Repository r : rs) {
|
||||
if (r.getCollectedFrom() != null && r.getCollectedFrom().equals(mode))
|
||||
reps.add(r);
|
||||
|
||||
}
|
||||
return reps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Repository> getRepositoriesOfUser(String userEmail,
|
||||
String page,
|
||||
String size) throws JSONException {
|
||||
|
||||
LOGGER.debug("Retreiving repositories of user : " + userEmail );
|
||||
UriComponents uriComponents = searchDatasource(page,size);
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setRegisteredby(userEmail);
|
||||
|
||||
try{
|
||||
long start = System.currentTimeMillis();
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
System.out.println("POST request finished in " + (end-start)+"ms");
|
||||
start=System.currentTimeMillis();
|
||||
List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs));
|
||||
end=System.currentTimeMillis();
|
||||
System.out.println("Converting json to repo list finished in " + (end-start)+"ms");
|
||||
start=System.currentTimeMillis();
|
||||
for (Repository r : repos)
|
||||
this.updateRepositoryInfo(r);
|
||||
end=System.currentTimeMillis();
|
||||
System.out.println("Updating "+repos.size()+" repository infos in " + (end-start)+"ms");
|
||||
return repos;
|
||||
}catch (Exception e){
|
||||
LOGGER.debug("Exception on getRepositoriesOfUser" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Repository getRepositoryById(String id) throws JSONException,ResourceNotFoundException {
|
||||
|
||||
LOGGER.debug("Retreiving repositories with id : " + id );
|
||||
Repository repo = null;
|
||||
UriComponents uriComponents = searchDatasource("0","100");
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setId(id);
|
||||
|
||||
try{
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
||||
|
||||
if(jsonArray.length() == 0)
|
||||
throw new ResourceNotFoundException();
|
||||
|
||||
repo = Converter.jsonToRepositoryObject(jsonArray.getJSONObject(0));
|
||||
return updateRepositoryInfo(repo);
|
||||
}catch (JSONException e){
|
||||
LOGGER.debug("Exception on getRepositoryById" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<AggregationDetails> getRepositoryAggregations(String id, int from, int size) throws JSONException {
|
||||
|
||||
LOGGER.debug("Retreiving aggregations for repository with id : " + id );
|
||||
UriComponents uriComponents = searchDatasource(from+"",size+"");
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setId(id);
|
||||
|
||||
List<AggregationDetails> aggregationHistory = new ArrayList<>();
|
||||
|
||||
try {
|
||||
long start = System.currentTimeMillis();
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
System.out.println("Aggregations request through rest template took " + (end-start)+"ms");
|
||||
JSONObject repository = new JSONObject(rs);
|
||||
|
||||
if(repository.getJSONArray("datasourceInfo").length() == 0)
|
||||
return aggregationHistory;
|
||||
|
||||
start = System.currentTimeMillis();
|
||||
aggregationHistory.addAll(Converter.getAggregationHistoryFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
|
||||
end = System.currentTimeMillis();
|
||||
|
||||
System.out.println("Getting aggregations history from json " + (end-start)+"ms");
|
||||
return aggregationHistory.size() == 0? aggregationHistory : aggregationHistory.stream()
|
||||
.sorted(Comparator.comparing(AggregationDetails::getDate).reversed())
|
||||
.limit(size)
|
||||
.collect(Collectors.toList());
|
||||
} catch (JSONException e) {
|
||||
LOGGER.debug("Exception on getRepositoryAggregations" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<AggregationDetails>> getRepositoryAggregationsByYear(String id) throws JSONException {
|
||||
LOGGER.debug("Retreiving aggregations (by year) for repository with id : " + id );
|
||||
UriComponents uriComponents = searchDatasource("0","100");
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setId(id);
|
||||
|
||||
List<AggregationDetails> aggregationHistory = new ArrayList<>();
|
||||
Map<String, List<AggregationDetails>> aggregationByYear = new HashMap<>();
|
||||
try {
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
JSONObject repository = new JSONObject(rs);
|
||||
|
||||
if(repository.getJSONArray("datasourceInfo").length() == 0)
|
||||
return aggregationByYear;
|
||||
|
||||
aggregationHistory.addAll(Converter.getAggregationHistoryFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
|
||||
return aggregationHistory.size() == 0? aggregationByYear:createYearMap(aggregationHistory);
|
||||
|
||||
} catch (JSONException e) {
|
||||
LOGGER.debug("Exception on getRepositoryAggregations" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String,List<AggregationDetails>> createYearMap(List<AggregationDetails> aggregationHistory) {
|
||||
Map<String, List<AggregationDetails>> aggregationByYear;
|
||||
aggregationHistory = aggregationHistory.stream()
|
||||
.sorted(Comparator.comparing(AggregationDetails::getDate).reversed())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return aggregationHistory.stream()
|
||||
.collect(Collectors.groupingBy(AggregationDetails::getYear));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Repository> getRepositoriesByName(String name,
|
||||
String page,
|
||||
String size) throws JSONException {
|
||||
|
||||
LOGGER.debug("Retreiving repositories with official name : " + name );
|
||||
UriComponents uriComponents = searchDatasource("0","100");
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setOfficialname(name);
|
||||
|
||||
try{
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs));
|
||||
for (Repository r : repos)
|
||||
updateRepositoryInfo(r);
|
||||
return repos;
|
||||
}catch (Exception e){
|
||||
LOGGER.debug("Exception on getRepositoriesByName" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RepositoryInterface> getRepositoryInterface(String id) throws JSONException {
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/")
|
||||
.path("/{id}")
|
||||
.build().expand(id).encode();
|
||||
|
||||
try{
|
||||
String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
|
||||
return Converter.jsonToRepositoryInterfaceList(new JSONObject(rs));
|
||||
}catch (Exception e ){
|
||||
LOGGER.debug("Exception on getRepositoryInterface" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Repository addRepository(String datatype,
|
||||
Repository repository) throws Exception {
|
||||
|
||||
LOGGER.debug("storing " + datatype + " repository with id: " + repository.getId());
|
||||
|
||||
repository.setCountryCode(countriesMap.get(repository.getCountryName()));
|
||||
repository.setActivationId(UUID.randomUUID().toString());
|
||||
repository.setCollectedFrom("infrastruct_::openaire");
|
||||
|
||||
if (datatype.equals("journal")) {
|
||||
repository.setId("openaire____::issn" + repository.getIssn());
|
||||
repository.setNamespacePrefix("issn" + repository.getIssn());
|
||||
this.storeRepository(repository, SecurityContextHolder.getContext().getAuthentication());
|
||||
}else if (datatype.equals("aggregator")) {
|
||||
repository.setId("openaire____::" + com.unboundid.util.Base64.encode(repository.getOfficialName()));
|
||||
repository.setNamespacePrefix(DigestUtils.md5Hex(repository.getOfficialName()).substring(0,12));
|
||||
this.storeRepository(repository, SecurityContextHolder.getContext().getAuthentication());
|
||||
}else {
|
||||
this.latentUpdate(repository, SecurityContextHolder.getContext().getAuthentication());
|
||||
}
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
/* update method acting as add -> send email with registration topic/body*/
|
||||
private Repository latentUpdate(Repository repository, Authentication authentication) throws Exception {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/update/")
|
||||
.build()
|
||||
.encode();
|
||||
|
||||
try {
|
||||
String json_repository = Converter.repositoryObjectToJson(repository);
|
||||
LOGGER.debug("JSON to add(update) -> " + json_repository);
|
||||
|
||||
HttpEntity<String> httpEntity = new HttpEntity<String>(json_repository, httpHeaders);
|
||||
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(),HttpMethod.POST, httpEntity, ResponseEntity.class);
|
||||
|
||||
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
|
||||
emailUtils.sendUserRegistrationEmail(repository, authentication);
|
||||
emailUtils.sendAdminRegistrationEmail(repository, authentication);
|
||||
} else
|
||||
LOGGER.debug(responseEntity.getBody().toString());
|
||||
|
||||
return repository;
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug("Exception on updateRepository" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Repository updateRepository(Repository repository,Authentication authentication) throws Exception {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/update/")
|
||||
.build()
|
||||
.encode();
|
||||
|
||||
try {
|
||||
String json_repository = Converter.repositoryObjectToJson(repository);
|
||||
|
||||
LOGGER.debug("JSON to update -> " + json_repository);
|
||||
|
||||
HttpEntity<String> httpEntity = new HttpEntity<String>(json_repository, httpHeaders);
|
||||
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(),HttpMethod.POST, httpEntity
|
||||
, ResponseEntity.class);
|
||||
|
||||
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
|
||||
emailUtils.sendUserUpdateRepositoryEmail(repository, authentication);
|
||||
emailUtils.sendAdminUpdateRepositoryEmail(repository, authentication);
|
||||
} else
|
||||
LOGGER.debug(responseEntity.getBody().toString());
|
||||
|
||||
return repository;
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug("Exception on updateRepository" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private void storeRepository(Repository repository, Authentication authentication) throws Exception {
|
||||
|
||||
Date utilDate = new Date();
|
||||
Timestamp date = new Timestamp(utilDate.getTime());
|
||||
repository.setDateOfCollection(date);
|
||||
repository.setAggregator("OPENAIRE");
|
||||
repository.setCountryCode(countriesMap.get(repository.getCountryName()));
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/add/")
|
||||
.build()
|
||||
.encode();
|
||||
String json_repository = Converter.repositoryObjectToJson(repository);
|
||||
HttpEntity<String> httpEntity = new HttpEntity <String> (json_repository,httpHeaders);
|
||||
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(),HttpMethod.POST, httpEntity, ResponseEntity.class);
|
||||
|
||||
if(responseEntity.getStatusCode().equals(HttpStatus.OK)) {
|
||||
emailUtils.sendUserRegistrationEmail(repository, authentication);
|
||||
emailUtils.sendAdminRegistrationEmail(repository, authentication);
|
||||
} else {
|
||||
LOGGER.debug(responseEntity.getBody().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRepositoryInterface(String id ,
|
||||
String registeredBy){
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/")
|
||||
.path("/{id}")
|
||||
.build().expand(id).encode();
|
||||
LOGGER.debug(uriComponents.toUri());
|
||||
restTemplate.delete(uriComponents.toUri());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryInterface addRepositoryInterface(String datatype,
|
||||
String repoId,
|
||||
String registeredBy,
|
||||
RepositoryInterface repositoryInterface) throws JSONException, ResourceNotFoundException, ValidatorServiceException {
|
||||
try {
|
||||
Repository e = this.getRepositoryById(repoId);
|
||||
repositoryInterface = createRepositoryInterface(e,repositoryInterface,datatype);
|
||||
String json_interface = Converter.repositoryInterfaceObjectToJson(e,repositoryInterface);
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/add/")
|
||||
.build()
|
||||
.encode();
|
||||
|
||||
HttpEntity<String> httpEntity = new HttpEntity <> (json_interface,httpHeaders);
|
||||
restTemplate.postForObject(uriComponents.toUri(),httpEntity,String.class);
|
||||
submitInterfaceValidation(e, registeredBy, repositoryInterface, false);
|
||||
|
||||
return repositoryInterface;
|
||||
|
||||
} catch (JSONException | ValidatorServiceException e) {
|
||||
LOGGER.debug("Exception on addRepositoryInterface" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryInterface updateRepositoryInterface(String repoId,
|
||||
String registeredBy,
|
||||
RepositoryInterface repositoryInterface) throws Exception {
|
||||
|
||||
this.updateBaseUrl(repoId,repositoryInterface.getId(),repositoryInterface.getBaseUrl());
|
||||
this.updateCompliance(repoId,repositoryInterface.getId(),repositoryInterface.getCompliance());
|
||||
this.updateValidationSet(repoId,repositoryInterface.getId(),repositoryInterface.getAccessSet());
|
||||
submitInterfaceValidation(getRepositoryById(repoId),registeredBy,repositoryInterface,true);
|
||||
return repositoryInterface;
|
||||
}
|
||||
|
||||
private void submitInterfaceValidation(Repository repo, String userEmail, RepositoryInterface iFace, boolean updateExisting) throws ValidatorServiceException {
|
||||
JobForValidation job = new JobForValidation();
|
||||
|
||||
job.setActivationId(UUID.randomUUID().toString());
|
||||
job.setAdminEmails(Collections.singletonList(this.adminEmail));
|
||||
job.setBaseUrl(iFace.getBaseUrl());
|
||||
job.setDatasourceId(repo.getId());
|
||||
job.setDesiredCompatibilityLevel(iFace.getDesiredCompatibilityLevel());
|
||||
job.setInterfaceId(iFace.getId());
|
||||
job.setOfficialName(repo.getOfficialName());
|
||||
job.setRepoType(repo.getDatasourceType());
|
||||
job.setUserEmail(userEmail);
|
||||
job.setValidationSet((iFace.getAccessSet().isEmpty() ? "none" : iFace.getAccessSet()));
|
||||
job.setRecords(-1);
|
||||
job.setRegistration(!updateExisting);
|
||||
job.setUpdateExisting(updateExisting);
|
||||
|
||||
this.validatorService.submitJobForValidation(job);
|
||||
}
|
||||
|
||||
private RepositoryInterface createRepositoryInterface(Repository repo, RepositoryInterface iFace, String datatype) {
|
||||
|
||||
iFace.setContentDescription("metadata");
|
||||
iFace.setCompliance("UNKNOWN");
|
||||
|
||||
if (datatype.equals("re3data"))
|
||||
iFace.setAccessFormat("oai_datacite");
|
||||
else
|
||||
iFace.setAccessFormat("oai_dc");
|
||||
|
||||
|
||||
if (repo.getDatasourceClass() != null && !repo.getDatasourceClass().isEmpty())
|
||||
iFace.setTypology(repo.getDatasourceClass());
|
||||
else if (datatype.equalsIgnoreCase("journal"))
|
||||
iFace.setTypology("pubsrepository::journal");
|
||||
else if (datatype.equalsIgnoreCase("aggregator"))
|
||||
iFace.setTypology("aggregator::pubsrepository::unknown");
|
||||
else if (datatype.equalsIgnoreCase("opendoar"))
|
||||
iFace.setTypology("pubsrepository::unknown");
|
||||
else if (datatype.equalsIgnoreCase("re3data"))
|
||||
iFace.setTypology("datarepository::unknown");
|
||||
|
||||
iFace.setRemovable(true);
|
||||
iFace.setAccessProtocol("oai");
|
||||
iFace.setMetadataIdentifierPath("//*[local-name()='header']/*[local-name()='identifier']");
|
||||
iFace.setId("api_________::" + repo.getId() + "::" + UUID.randomUUID().toString().substring(0, 8));
|
||||
if (iFace.getAccessSet() == null || iFace.getAccessSet().isEmpty()) {
|
||||
LOGGER.debug("set is empty: " + iFace.getAccessSet());
|
||||
iFace.removeAccessSet();
|
||||
iFace.setAccessSet("none");
|
||||
}
|
||||
return iFace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDnetCountries() {
|
||||
LOGGER.debug("Getting dnet-countries!");
|
||||
return Converter.readFile("countries.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTypologies() {
|
||||
return Converter.readFile("typologies.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Timezone> getTimezones() {
|
||||
List<String> timezones = Converter.readFile("timezones.txt");
|
||||
return Converter.toTimezones(timezones);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUrlsOfUserRepos(String userEmail,
|
||||
String page,
|
||||
String size){
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/api/baseurl/")
|
||||
.path("/{page}/{size}")
|
||||
.build().expand(page,size).encode();
|
||||
|
||||
try{
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setRegisteredby(userEmail);
|
||||
return Arrays.asList(restTemplate.postForObject(uriComponents.toUri(),requestFilter, String[].class));
|
||||
}catch (Exception e){
|
||||
LOGGER.debug("Exception on addRepositoryInterface" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDatasourceVocabularies(String mode) {
|
||||
|
||||
List<String> resultSet = new ArrayList<>();
|
||||
for (Map.Entry<String, String> entry : this.getVocabulary("dnet:datasource_typologies").getAsMap().entrySet()) {
|
||||
if (mode.equalsIgnoreCase("aggregator")) {
|
||||
if (entry.getKey().contains("aggregator"))
|
||||
resultSet.add(entry.getValue());
|
||||
} else if (mode.equalsIgnoreCase("journal")) {
|
||||
if (entry.getKey().contains("journal"))
|
||||
resultSet.add(entry.getValue());
|
||||
} else if (mode.equalsIgnoreCase("opendoar")) {
|
||||
if (entry.getKey().contains("pubsrepository"))
|
||||
resultSet.add(entry.getValue());
|
||||
} else if (mode.equalsIgnoreCase("re3data")) {
|
||||
if (entry.getKey().contains("datarepository"))
|
||||
resultSet.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return resultSet;
|
||||
}
|
||||
|
||||
private Vocabulary getVocabulary(String vocName) {
|
||||
|
||||
if (!vocabularyMap.containsKey(vocName)) {
|
||||
vocabularyMap.put(vocName, vocabularyLoader.getVocabulary(vocName, Locale.ENGLISH, Locale.ROOT));
|
||||
}
|
||||
return vocabularyMap.get(vocName);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, String> getCompatibilityClasses(String mode) {
|
||||
|
||||
LOGGER.debug("Getting compatibility classes for mode: " + mode);
|
||||
Map<String, String> retMap = new HashMap<String, String>();
|
||||
|
||||
Map<String, String> compatibilityClasses = this.getVocabulary("dnet:compatibilityLevel").getAsMap();
|
||||
boolean foundData = false;
|
||||
for (Map.Entry<String, String> entry : compatibilityClasses.entrySet()) {
|
||||
if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_ALL))
|
||||
return compatibilityClasses;
|
||||
else if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_RE3DATA)) {
|
||||
if (entry.getKey().matches("^openaire[1-9].0_data$")) {
|
||||
retMap.put(entry.getKey(), entry.getValue());
|
||||
foundData = true;
|
||||
}
|
||||
} else {
|
||||
if (entry.getKey().matches("^openaire[1-9].0$") || entry.getKey().equals("driver"))
|
||||
retMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
//TODO TO BE REMOVED WHEN VOCABULARIES ARE UPDATED
|
||||
if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_RE3DATA) && !foundData)
|
||||
retMap.put("openaire2.0_data", "OpenAIRE Data (funded, referenced datasets)");
|
||||
|
||||
return retMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getDatasourceClasses(String mode) {
|
||||
|
||||
LOGGER.debug("Getting datasource classes for mode: " + mode);
|
||||
|
||||
Map<String, String> retMap = new HashMap<String, String>();
|
||||
|
||||
for (Map.Entry<String, String> entry : this.getVocabulary("dnet:datasource_typologies").getAsMap().entrySet()) {
|
||||
if (mode.equalsIgnoreCase("aggregator")) {
|
||||
if (entry.getKey().contains("aggregator"))
|
||||
retMap.put(entry.getKey(), entry.getValue());
|
||||
} else if (mode.equalsIgnoreCase("journal")) {
|
||||
if (entry.getKey().contains("journal"))
|
||||
retMap.put(entry.getKey(), entry.getValue());
|
||||
} else if (mode.equalsIgnoreCase("opendoar")) {
|
||||
if (entry.getKey().contains("pubsrepository"))
|
||||
retMap.put(entry.getKey(), entry.getValue());
|
||||
} else if (mode.equalsIgnoreCase("re3data")) {
|
||||
if (entry.getKey().contains("datarepository"))
|
||||
retMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
return filterResults(retMap,mode);
|
||||
|
||||
}
|
||||
|
||||
private Map<String,String> filterResults(Map<String, String> map,String mode) {
|
||||
|
||||
HashMap<String,String> filteredMap = new HashMap<>();
|
||||
for(String key:map.keySet())
|
||||
if(dataSourceClass.get(mode).contains(key))
|
||||
filteredMap.put(key,map.get(key));
|
||||
|
||||
return filteredMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCountryName(String countryCode) {
|
||||
return inverseCountriesMap.get(countryCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetricsInfo getMetricsInfoForRepository(String repoId) throws RepositoryServiceException {
|
||||
try {
|
||||
|
||||
MetricsInfo metricsInfo = new MetricsInfo();
|
||||
metricsInfo.setDiagramsBaseURL(this.usageStatisticsDiagramsBaseURL);
|
||||
metricsInfo.setMetricsNumbers(getMetricsNumbers(getOpenAIREId(repoId)));
|
||||
return metricsInfo;
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while getting metrics info for repository: ", e);
|
||||
emailUtils.reportException(e);
|
||||
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getListLatestUpdate(String mode) throws JSONException {
|
||||
if(mode.equals("opendoar"))
|
||||
return Collections.singletonMap("lastCollectionDate", getRepositoryInterface("openaire____::"+mode).get(0).getLastCollectionDate());
|
||||
else
|
||||
/*
|
||||
* first api of re3data has null value on collection date
|
||||
* */
|
||||
return Collections.singletonMap("lastCollectionDate", getRepositoryInterface("openaire____::"+mode).get(1).getLastCollectionDate());
|
||||
}
|
||||
|
||||
private void updateValidationSet(String repositoryId, String repositoryInterfaceId, String validationSet) throws Exception {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/oaiset")
|
||||
.queryParam("dsId",repositoryId)
|
||||
.queryParam("apiId",repositoryInterfaceId)
|
||||
.queryParam("oaiSet",validationSet)
|
||||
.build().encode();
|
||||
restTemplate.exchange(uriComponents.toUri(),HttpMethod.POST, null, ResponseEntity.class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void updateBaseUrl(String repositoryId, String repositoryInterfaceId, String baseUrl) {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/baseurl")
|
||||
.queryParam("dsId",repositoryId)
|
||||
.queryParam("apiId",repositoryInterfaceId)
|
||||
.queryParam("baseUrl",baseUrl)
|
||||
.build().encode();
|
||||
restTemplate.postForObject(uriComponents.toUri(),null,String.class);
|
||||
}
|
||||
|
||||
private void updateCompliance(String repositoryId, String repositoryInterfaceId,String compliance) {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/compliance")
|
||||
.queryParam("dsId",repositoryId)
|
||||
.queryParam("apiId",repositoryInterfaceId)
|
||||
.queryParam("compliance",compliance)
|
||||
.build().encode();
|
||||
restTemplate.postForObject(uriComponents.toUri(),null,String.class);
|
||||
}
|
||||
|
||||
private MetricsNumbers getMetricsNumbers(String openAIREID) throws BrokerException {
|
||||
|
||||
//build the uri params
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.usageStatisticsNumbersBaseURL + openAIREID + "/clicks");
|
||||
|
||||
//create new template engine
|
||||
RestTemplate template = new RestTemplate();
|
||||
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
||||
ResponseEntity<MetricsNumbers> resp;
|
||||
try {
|
||||
//communicate with endpoint
|
||||
resp = template.exchange(
|
||||
builder.build().encode().toUri(),
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
new ParameterizedTypeReference<MetricsNumbers>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on getMetricsNumbers" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
return resp.getBody();
|
||||
}
|
||||
|
||||
private String getOpenAIREId(String repoId) {
|
||||
|
||||
if (repoId != null && repoId.contains("::")) {
|
||||
return repoId.split("::")[0] + "::" + DigestUtils.md5Hex(repoId.split("::")[1]);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private UriComponents searchDatasource(String page,String size){
|
||||
|
||||
return UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/search/")
|
||||
.path("/{page}/{size}/")
|
||||
.queryParam("requestSortBy","officialname")
|
||||
.queryParam("order","ASCENDING")
|
||||
.build().expand(page, size).encode();
|
||||
}
|
||||
|
||||
private UriComponents searchSnipperDatasource(String page,String size){
|
||||
|
||||
return UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/searchsnippet/")
|
||||
.path("/{page}/{size}/")
|
||||
.queryParam("requestSortBy","officialname")
|
||||
.queryParam("order","ASCENDING")
|
||||
.build().expand(page, size).encode();
|
||||
}
|
||||
|
||||
private UriComponents searchRegisteredDatasource(String requestSortBy, String order, String page,String size){
|
||||
|
||||
return UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/searchregistered/")
|
||||
.path("/{page}/{size}/")
|
||||
.queryParam("requestSortBy",requestSortBy)
|
||||
.queryParam("order",order)
|
||||
.build().expand(page, size).encode();
|
||||
}
|
||||
|
||||
private String getRepositoryType(String typology){
|
||||
return invertedDataSourceClass.get(typology);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
|
||||
import eu.dnetlib.repo.manager.exception.EndPointException;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public interface StatsService {
|
||||
|
||||
Map getStatistics() ;
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.repo.manager.service.customHystrixCommands.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("statsService")
|
||||
public class StatsServiceImpl implements StatsService {
|
||||
|
||||
@Autowired
|
||||
RestTemplate restTemplate;
|
||||
|
||||
@Value("${search.api.baseAddress}")
|
||||
private String baseAddress;
|
||||
@Value("${search.api.usagestats}")
|
||||
private String usagestatsBaseAddress;
|
||||
@Value("${search.api.usageEvents}")
|
||||
private String usagestatsEvents;
|
||||
|
||||
@Override
|
||||
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<>();
|
||||
stats.put("aggregators",aggregatorsHystrixCommand.execute());
|
||||
stats.put("dataRepositories",dataRepositoriesHystrixCommand.execute());
|
||||
stats.put("literature",literatureHystrixCommand.execute());
|
||||
stats.put("journal",journalHystrixCommand.execute());
|
||||
stats.put("publications",publicationHystrixCommand.execute());
|
||||
stats.put("datasets",datasetsHystrixCommand.execute());
|
||||
stats.put("software",softwareHystrixCommand.execute());
|
||||
stats.put("lastYearUsagestats", lastYearUsageStatsHystrixCommand.execute());
|
||||
stats.put("usagestats",usageStatsTotalHystrixCommand.execute());
|
||||
return stats;
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper;
|
||||
import org.json.JSONException;
|
||||
|
||||
|
||||
public interface SushiliteService {
|
||||
|
||||
|
||||
ReportResponseWrapper getReportResults(String page,
|
||||
String pageSize,
|
||||
String Report,
|
||||
String Release,
|
||||
String RequestorID,
|
||||
String BeginDate,
|
||||
String EndDate,
|
||||
String RepositoryIdentifier,
|
||||
String ItemIdentifier,
|
||||
String ItemDataType,
|
||||
String Granularity,
|
||||
String Pretty) throws JSONException;
|
||||
|
||||
}
|
|
@ -1,116 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.usagestats.sushilite.domain.ReportItem;
|
||||
import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service("sushiliteService")
|
||||
public class SushiliteServiceImpl implements SushiliteService {
|
||||
|
||||
|
||||
@Value("${services.repomanager.usagestats.sushiliteEndpoint}")
|
||||
private String usagestatsSushiliteEndpoint;
|
||||
|
||||
@Autowired
|
||||
private EmailUtils emailUtils;
|
||||
|
||||
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger.getLogger(SushiliteServiceImpl.class);
|
||||
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public ReportResponseWrapper getReportResults(String page,
|
||||
String pageSize,
|
||||
String Report,
|
||||
String Release,
|
||||
String RequestorID,
|
||||
String BeginDate,
|
||||
String EndDate,
|
||||
String RepositoryIdentifier,
|
||||
String ItemIdentifier,
|
||||
String ItemDataType,
|
||||
String Granularity,
|
||||
String Pretty) {
|
||||
|
||||
//build the uri params
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.usagestatsSushiliteEndpoint + "GetReport/")
|
||||
.queryParam("Report", Report)
|
||||
.queryParam("Release", Release)
|
||||
.queryParam("RequestorID", RequestorID)
|
||||
.queryParam("BeginDate", BeginDate)
|
||||
.queryParam("EndDate", EndDate)
|
||||
.queryParam("RepositoryIdentifier", RepositoryIdentifier)
|
||||
.queryParam("ItemIdentifier", ItemIdentifier)
|
||||
.queryParam("ItemDataType", ItemDataType)
|
||||
.queryParam("Granularity", Granularity)
|
||||
.queryParam("Pretty", Pretty);
|
||||
|
||||
//create new template engine
|
||||
RestTemplate template = new RestTemplate();
|
||||
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
||||
|
||||
ResponseEntity<ReportResponseWrapper> resp;
|
||||
try {
|
||||
//communicate with endpoint
|
||||
resp = template.exchange(
|
||||
builder.build().encode().toUri(),
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
new ParameterizedTypeReference<ReportResponseWrapper>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on getReportResults" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
// check remote api's response
|
||||
System.out.println("sushi responded status " + resp.getStatusCode());
|
||||
|
||||
// get the items corresponding to the requested page
|
||||
List<ReportItem> requestedItemList = new ArrayList<>();
|
||||
if (resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems() != null) {
|
||||
try {
|
||||
int totalItems = resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems().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 = resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems().subList(offset,upperIndex);
|
||||
}
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
LOGGER.debug("Exception on getReportResults - trying to cast strings to integers", e);
|
||||
//emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ReportResponseWrapper newReportResponse = resp.getBody();
|
||||
newReportResponse.getReportResponse().getReportWrapper().getReport().getCustomer().setReportItems(requestedItemList);
|
||||
|
||||
|
||||
return newReportResponse;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
|
||||
public interface UserService {
|
||||
|
||||
ResponseEntity<Object> login();
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service("userService")
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger
|
||||
.getLogger(UserServiceImpl.class);
|
||||
|
||||
@Value("${oidc.issuer}")
|
||||
private String oidc_issuer;
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> login() {
|
||||
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||
LOGGER.debug("User authentication : " + authentication);
|
||||
Map<String,Object> body = new HashMap<>();
|
||||
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());
|
||||
List<String> roles = authentication.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList());
|
||||
body.put("role",roles);
|
||||
|
||||
return new ResponseEntity<>(body, HttpStatus.OK);
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import eu.dnetlib.domain.functionality.validator.JobResultEntry;
|
||||
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.shared.InterfaceInformation;
|
||||
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
public interface ValidatorService {
|
||||
|
||||
|
||||
JobForValidation submitJobForValidation(JobForValidation jobForValidation) throws ValidatorServiceException;
|
||||
|
||||
ResponseEntity<Object> reSubmitJobForValidation(String email, String jobId) throws JSONException, ValidatorServiceException;
|
||||
|
||||
List<RuleSet> getRuleSets(String mode);
|
||||
|
||||
List<String> getSetsOfRepository(String url);
|
||||
|
||||
boolean identifyRepo(String url);
|
||||
|
||||
RuleSet getRuleSet(String acronym);
|
||||
|
||||
List<StoredJob> getStoredJobsNew(String user,
|
||||
String jobType,
|
||||
String offset,
|
||||
String limit,
|
||||
String dateFrom,
|
||||
String dateTo,
|
||||
String validationStatus) throws ValidatorServiceException;
|
||||
|
||||
int getStoredJobsTotalNumberNew(String user, String jobType, String validationStatus) throws ValidatorServiceException;
|
||||
|
||||
InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException;
|
||||
|
||||
List<StoredJob> getJobsSummary(String repoId, int limit) throws ValidatorServiceException, ResourceNotFoundException, JSONException;
|
||||
}
|
|
@ -1,233 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import eu.dnetlib.domain.functionality.validator.JobResultEntry;
|
||||
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import eu.dnetlib.repo.manager.shared.Constants;
|
||||
import eu.dnetlib.repo.manager.shared.InterfaceInformation;
|
||||
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
|
||||
import eu.dnetlib.repo.manager.utils.OaiTools;
|
||||
import gr.uoa.di.driver.util.ServiceLocator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service("validatorService")
|
||||
public class ValidatorServiceImpl implements ValidatorService {
|
||||
|
||||
@Autowired
|
||||
private MonitorServiceImpl monitorApi;
|
||||
|
||||
@Autowired
|
||||
private RepositoryService repositoryService;
|
||||
|
||||
@Resource(name = "validatorServiceLocator")
|
||||
private ServiceLocator<eu.dnetlib.api.functionality.ValidatorService> validatorServiceLocator;
|
||||
|
||||
private eu.dnetlib.api.functionality.ValidatorService getValidationService() {
|
||||
return this.validatorServiceLocator.getService();
|
||||
}
|
||||
|
||||
public ServiceLocator<eu.dnetlib.api.functionality.ValidatorService> getValidatorServiceLocator() {
|
||||
return validatorServiceLocator;
|
||||
}
|
||||
|
||||
public void setValidatorServiceLocator(ServiceLocator<eu.dnetlib.api.functionality.ValidatorService> validatorServiceLocator) {
|
||||
this.validatorServiceLocator = validatorServiceLocator;
|
||||
}
|
||||
|
||||
private Map<String, List<RuleSet>> rulesetMap = new ConcurrentHashMap<String, List<RuleSet>>();
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(ValidatorServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private EmailUtils emailUtils;
|
||||
|
||||
@PostConstruct
|
||||
private void loadRules(){
|
||||
LOGGER.debug("PostConstruct method! Load rules!");
|
||||
try {
|
||||
for (RuleSet ruleSet : getValidationService().getRuleSets()) {
|
||||
if (ruleSet.getVisibility() != null && ruleSet.getVisibility().contains("development")) {
|
||||
String key = "";
|
||||
if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0_data$"))
|
||||
key = Constants.VALIDATION_MODE_DATA;
|
||||
else if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0$") || ruleSet.getGuidelinesAcronym().equals("driver"))
|
||||
key = Constants.VALIDATION_MODE_LITERATURE;
|
||||
else if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0_cris$"))
|
||||
key = Constants.VALIDATION_MODE_CRIS;
|
||||
|
||||
if (rulesetMap.containsKey(key))
|
||||
rulesetMap.get(key).add(ruleSet);
|
||||
else {
|
||||
List<RuleSet> ruleSets = new ArrayList<RuleSet>();
|
||||
ruleSets.add(ruleSet);
|
||||
rulesetMap.put(key, ruleSets);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ValidatorServiceException e) {
|
||||
LOGGER.error(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ROLE_USER') and #jobForValidation.userEmail == authentication.userInfo.email")
|
||||
public JobForValidation submitJobForValidation(JobForValidation jobForValidation) throws ValidatorServiceException {
|
||||
LOGGER.debug("Submit job for validation with id : " + jobForValidation.getDatasourceId());
|
||||
try {
|
||||
emailUtils.sendSubmitJobForValidationEmail(SecurityContextHolder.getContext().getAuthentication(),jobForValidation);
|
||||
this.getValidationService().submitValidationJob(jobForValidation);
|
||||
} catch (ValidatorServiceException e) {
|
||||
LOGGER.debug("Exception on submitJobForValidation" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(e);
|
||||
}
|
||||
return jobForValidation;
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ROLE_USER') and #email == authentication.userInfo.email")
|
||||
public ResponseEntity<Object> reSubmitJobForValidation(String email,
|
||||
String jobId) throws JSONException, ValidatorServiceException {
|
||||
LOGGER.debug("Resubmit validation job with id : " + jobId);
|
||||
StoredJob job = monitorApi.getJobSummary(jobId, "all");
|
||||
Set<Integer> contentRules = new HashSet<Integer>();
|
||||
Set<Integer> usageRules = new HashSet<Integer>();
|
||||
|
||||
RuleSet ruleSet = null;
|
||||
for (List<RuleSet> ruleSets : this.rulesetMap.values()) {
|
||||
for (RuleSet rSet : ruleSets)
|
||||
if (rSet.getGuidelinesAcronym().equals(job.getDesiredCompatibilityLevel())) {
|
||||
ruleSet = rSet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ruleSet != null){
|
||||
for (int ruleId : job.getRules()) {
|
||||
if (ruleSet.getContentRulesIds().contains(ruleId))
|
||||
contentRules.add(ruleId);
|
||||
else if (ruleSet.getUsageRulesIds().contains(ruleId))
|
||||
usageRules.add(ruleId);
|
||||
}
|
||||
}
|
||||
if (!contentRules.isEmpty())
|
||||
job.setSelectedContentRules(contentRules);
|
||||
if (!usageRules.isEmpty())
|
||||
job.setSelectedUsageRules(usageRules);
|
||||
this.submitJobForValidation(job);
|
||||
return new ResponseEntity<>("OK",HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RuleSet> getRuleSets(String mode) {
|
||||
LOGGER.info("Getting rulesets for mode: " + mode);
|
||||
return rulesetMap.get(mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSetsOfRepository(String url) {
|
||||
LOGGER.debug("Getting sets of repository with url : " + url);
|
||||
try {
|
||||
return OaiTools.getSetsOfRepo(url);
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug("Exception on getSetsOfRepository" , e);
|
||||
emailUtils.reportException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean identifyRepo(String url) {
|
||||
LOGGER.debug("Identify repository with url : " + url);
|
||||
try {
|
||||
return OaiTools.identifyRepository(url);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while identifying repository with url: " + url, e);
|
||||
emailUtils.reportException(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuleSet getRuleSet(String acronym) {
|
||||
LOGGER.debug("Getting ruleset with acronym : " + acronym);
|
||||
RuleSet ruleSet = null;
|
||||
try {
|
||||
for (List<RuleSet> ruleSets : this.rulesetMap.values()) {
|
||||
for (RuleSet rSet : ruleSets)
|
||||
if (rSet.getGuidelinesAcronym().equals(acronym)) {
|
||||
ruleSet = rSet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ruleSet;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error getting ruleset", e);
|
||||
emailUtils.reportException(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public List<StoredJob> getStoredJobsNew(String user,
|
||||
String jobType,
|
||||
String offset,
|
||||
String limit,
|
||||
String dateFrom,
|
||||
String dateTo,
|
||||
String validationStatus ) throws ValidatorServiceException {
|
||||
return getValidationService().getStoredJobsNew(user, jobType, Integer.parseInt(offset), Integer.parseInt(limit), dateFrom, dateTo, validationStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredJobsTotalNumberNew(String user, String jobType, String validationStatus) throws ValidatorServiceException {
|
||||
return getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException {
|
||||
try {
|
||||
LOGGER.debug("Getting interface information with url: " + baseUrl);
|
||||
InterfaceInformation interfaceInformation = new InterfaceInformation();
|
||||
interfaceInformation.setIdentified(this.identifyRepo(baseUrl));
|
||||
if (interfaceInformation.isIdentified())
|
||||
interfaceInformation.setSets(this.getSetsOfRepository(baseUrl));
|
||||
|
||||
return interfaceInformation;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error getting interface information with url: " + baseUrl, e);
|
||||
emailUtils.reportException(e);
|
||||
throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.GENERAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoredJob> getJobsSummary(String repoId, int limit) throws JSONException, ValidatorServiceException {
|
||||
return getValidationService().getJobSummary(repositoryService.getRepositoryInterface(repoId).stream().map(RepositoryInterface::getBaseUrl).collect(Collectors.toList()),limit);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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,65 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public class AggregationDetails implements IsSerializable{
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Aggregations implements IsSerializable{
|
||||
|
||||
private List<AggregationDetails> aggregationHistory = new ArrayList<>();
|
||||
private AggregationDetails lastCollection;
|
||||
private AggregationDetails lastTransformation;
|
||||
|
||||
public Aggregations() {
|
||||
}
|
||||
|
||||
public List<AggregationDetails> getAggregationHistory() {
|
||||
return aggregationHistory;
|
||||
}
|
||||
|
||||
public void setAggregationHistory(List<AggregationDetails> aggregationHistory) {
|
||||
this.aggregationHistory = aggregationHistory;
|
||||
}
|
||||
|
||||
public AggregationDetails getLastCollection() {
|
||||
return lastCollection;
|
||||
}
|
||||
|
||||
public void setLastCollection(AggregationDetails lastCollection) {
|
||||
this.lastCollection = lastCollection;
|
||||
}
|
||||
|
||||
public AggregationDetails getLastTransformation() {
|
||||
return lastTransformation;
|
||||
}
|
||||
|
||||
public void setLastTransformation(AggregationDetails lastTransformation) {
|
||||
this.lastTransformation = lastTransformation;
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
|
||||
/**
|
||||
* Created by stefanos on 27-Oct-16.
|
||||
*/
|
||||
public class BrokerException extends Exception {
|
||||
|
||||
public BrokerException(Throwable th) {
|
||||
super(th);
|
||||
}
|
||||
|
||||
public BrokerException() {
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 23/12/15.
|
||||
*/
|
||||
|
||||
public class Constants implements IsSerializable {
|
||||
|
||||
public static final String MODE_LOCAL = "local";
|
||||
public static final String MODE_DNET = "dnet";
|
||||
public static final String MODE_LDAP = "ldap";
|
||||
public static final String ENV_LAREFERENCIA = "lareferencia";
|
||||
|
||||
public static final String ENV_MINCYT = "mincyt";
|
||||
public static final String ENV_OPENAIRE_PRODUCTION = "openaire-production";
|
||||
public static final String ENV_OPENAIRE_BETA = "openaire-beta";
|
||||
public static final String ENV_DEVELOPMENT = "development";
|
||||
public static final String LATITUDE_PATTERN = "^(\\+|-)?(?:90(?:(?:\\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\\.[0-9]{1,6})?))$";
|
||||
|
||||
public static final String LONGITUDE_PATTERN = "^(\\+|-)?(?:180(?:(?:\\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\\.[0-9]{1,6})?))$";
|
||||
public static final String EMAIL_PATTERN = "^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$";
|
||||
|
||||
|
||||
public static final String REPOSITORY_MODE_OPENDOAR = "opendoar";
|
||||
public static final String REPOSITORY_MODE_RE3DATA = "re3data";
|
||||
public static final String REPOSITORY_MODE_JOURNAL = "journal";
|
||||
public static final String REPOSITORY_MODE_AGGREGATOR = "aggregator";
|
||||
public static final String REPOSITORY_MODE_ALL = "all";
|
||||
|
||||
public static final String VALIDATION_MODE_LITERATURE = "literature";
|
||||
public static final String VALIDATION_MODE_DATA = "data";
|
||||
public static final String VALIDATION_MODE_CRIS = "cris";
|
||||
|
||||
public static final String VALIDATION_JOB_TYPE_COMPATIBILITY_TEST = "Compatibility Test";
|
||||
public static final String VALIDATION_JOB_TYPE_REGISTRATION_REQUEST = "Registration Request";
|
||||
public static final String VALIDATION_JOB_TYPE_WORKFLOW_REQUEST = "Workflow Request";
|
||||
|
||||
public static final String VALIDATION_JOB_STATUS_SUCCESSFUL = "successful";
|
||||
public static final String VALIDATION_JOB_STATUS_FAILED = "failed";
|
||||
public static final String VALIDATION_JOB_STATUS_ONGOING = "ongoing";
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
public class Country {
|
||||
|
||||
private String name;
|
||||
private String code;
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
|
||||
/**
|
||||
* Created by stefania on 12/17/15.
|
||||
*/
|
||||
public class DatasourceRegistrationState extends WizardState implements IsSerializable {
|
||||
|
||||
private String mode;
|
||||
private String selectedRepositoryId;
|
||||
|
||||
private Repository repository;
|
||||
|
||||
public DatasourceRegistrationState() {
|
||||
}
|
||||
|
||||
public DatasourceRegistrationState(String mode, String selectedRepositoryId, Repository repository) {
|
||||
this.mode = mode;
|
||||
this.selectedRepositoryId = selectedRepositoryId;
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public String getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setMode(String mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public String getSelectedRepositoryId() {
|
||||
return selectedRepositoryId;
|
||||
}
|
||||
|
||||
public void setSelectedRepositoryId(String selectedRepositoryId) {
|
||||
this.selectedRepositoryId = selectedRepositoryId;
|
||||
}
|
||||
|
||||
public Repository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
public void setRepository(Repository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 21/12/15.
|
||||
*/
|
||||
public class DatasourceVocabularies implements IsSerializable {
|
||||
|
||||
private Map<String, String> countries;
|
||||
private List<Timezone> timezones;
|
||||
private Map<String, String> datasourceClasses;
|
||||
private List<String> typologies;
|
||||
private Map<String, String> compatibilityLevels;
|
||||
|
||||
public DatasourceVocabularies() {
|
||||
}
|
||||
|
||||
public Map<String, String> getCountries() {
|
||||
return countries;
|
||||
}
|
||||
|
||||
public void setCountries(Map<String, String> countries) {
|
||||
this.countries = countries;
|
||||
}
|
||||
|
||||
public List<Timezone> getTimezones() {
|
||||
return timezones;
|
||||
}
|
||||
|
||||
public void setTimezones(List<Timezone> timezones) {
|
||||
this.timezones = timezones;
|
||||
}
|
||||
|
||||
public Map<String, String> getDatasourceClasses() {
|
||||
return datasourceClasses;
|
||||
}
|
||||
|
||||
public void setDatasourceClasses(Map<String, String> datasourceClasses) {
|
||||
this.datasourceClasses = datasourceClasses;
|
||||
}
|
||||
|
||||
public List<String> getTypologies() {
|
||||
return typologies;
|
||||
}
|
||||
|
||||
public void setTypologies(List<String> typologies) {
|
||||
this.typologies = typologies;
|
||||
}
|
||||
|
||||
public Map<String, String> getCompatibilityLevels() {
|
||||
return compatibilityLevels;
|
||||
}
|
||||
|
||||
public void setCompatibilityLevels(Map<String, String> compatibilityLevels) {
|
||||
this.compatibilityLevels = compatibilityLevels;
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 14/1/16.
|
||||
*/
|
||||
public class DatasourcesCollection implements IsSerializable{
|
||||
|
||||
private List<Repository> datasourcesOfUser;
|
||||
private List<Repository> sharedDatasources;
|
||||
private List<Repository> datasourcesOfOthers;
|
||||
|
||||
public DatasourcesCollection() {
|
||||
this.datasourcesOfOthers = new ArrayList<Repository>();
|
||||
this.datasourcesOfUser = new ArrayList<Repository>();
|
||||
this.datasourcesOfOthers = new ArrayList<Repository>();
|
||||
}
|
||||
|
||||
public List<Repository> getDatasourcesOfUser() {
|
||||
return datasourcesOfUser;
|
||||
}
|
||||
|
||||
public void setDatasourcesOfUser(List<Repository> datasourcesOfUser) {
|
||||
this.datasourcesOfUser = datasourcesOfUser;
|
||||
}
|
||||
|
||||
public List<Repository> getDatasourcesOfOthers() {
|
||||
return datasourcesOfOthers;
|
||||
}
|
||||
|
||||
public void setDatasourcesOfOthers(List<Repository> datasourcesOfOthers) {
|
||||
this.datasourcesOfOthers = datasourcesOfOthers;
|
||||
}
|
||||
|
||||
public List<Repository> getSharedDatasources() {
|
||||
return sharedDatasources;
|
||||
}
|
||||
|
||||
public void setSharedDatasources(List<Repository> sharedDatasources) {
|
||||
this.sharedDatasources = sharedDatasources;
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 7/1/16.
|
||||
*/
|
||||
public class InterfaceInformation implements IsSerializable {
|
||||
|
||||
private boolean identified;
|
||||
private List<String> sets;
|
||||
private List<String> adminEmails;
|
||||
|
||||
public InterfaceInformation() {
|
||||
}
|
||||
|
||||
public boolean isIdentified() {
|
||||
return identified;
|
||||
}
|
||||
|
||||
public void setIdentified(boolean identified) {
|
||||
this.identified = identified;
|
||||
}
|
||||
|
||||
public List<String> getSets() {
|
||||
return sets;
|
||||
}
|
||||
|
||||
public void setSets(List<String> sets) {
|
||||
this.sets = sets;
|
||||
}
|
||||
|
||||
public List<String> getAdminEmails() {
|
||||
return adminEmails;
|
||||
}
|
||||
|
||||
public void setAdminEmails(List<String> adminEmails) {
|
||||
this.adminEmails = adminEmails;
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 29/3/16.
|
||||
*/
|
||||
public class JobsOfUser implements IsSerializable {
|
||||
|
||||
private int totalJobs;
|
||||
private int totalJobsSuccessful;
|
||||
private int totalJobsFailed;
|
||||
private int totalJobsOngoing;
|
||||
|
||||
private List<StoredJob> jobs;
|
||||
|
||||
public int getTotalJobs() {
|
||||
return totalJobs;
|
||||
}
|
||||
|
||||
public void setTotalJobs(int totalJobs) {
|
||||
this.totalJobs = totalJobs;
|
||||
}
|
||||
|
||||
public int getTotalJobsSuccessful() {
|
||||
return totalJobsSuccessful;
|
||||
}
|
||||
|
||||
public void setTotalJobsSuccessful(int totalJobsSuccessful) {
|
||||
this.totalJobsSuccessful = totalJobsSuccessful;
|
||||
}
|
||||
|
||||
public int getTotalJobsFailed() {
|
||||
return totalJobsFailed;
|
||||
}
|
||||
|
||||
public void setTotalJobsFailed(int totalJobsFailed) {
|
||||
this.totalJobsFailed = totalJobsFailed;
|
||||
}
|
||||
|
||||
public int getTotalJobsOngoing() {
|
||||
return totalJobsOngoing;
|
||||
}
|
||||
|
||||
public void setTotalJobsOngoing(int totalJobsOngoing) {
|
||||
this.totalJobsOngoing = totalJobsOngoing;
|
||||
}
|
||||
|
||||
public List<StoredJob> getJobs() {
|
||||
return jobs;
|
||||
}
|
||||
|
||||
public void setJobs(List<StoredJob> jobs) {
|
||||
this.jobs = jobs;
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefania on 11/6/17.
|
||||
*/
|
||||
public class MetricsInfo implements IsSerializable {
|
||||
|
||||
private MetricsNumbers metricsNumbers;
|
||||
private String diagramsBaseURL;
|
||||
|
||||
public MetricsInfo() {
|
||||
}
|
||||
|
||||
public MetricsInfo(MetricsNumbers metricsNumbers, String diagramsBaseURL) {
|
||||
this.metricsNumbers = metricsNumbers;
|
||||
this.diagramsBaseURL = diagramsBaseURL;
|
||||
}
|
||||
|
||||
public MetricsNumbers getMetricsNumbers() {
|
||||
return metricsNumbers;
|
||||
}
|
||||
|
||||
public void setMetricsNumbers(MetricsNumbers metricsNumbers) {
|
||||
this.metricsNumbers = metricsNumbers;
|
||||
}
|
||||
|
||||
public String getDiagramsBaseURL() {
|
||||
return diagramsBaseURL;
|
||||
}
|
||||
|
||||
public void setDiagramsBaseURL(String diagramsBaseURL) {
|
||||
this.diagramsBaseURL = diagramsBaseURL;
|
||||
}
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by stefania on 11/7/17.
|
||||
*/
|
||||
public class MetricsNumbers implements IsSerializable {
|
||||
|
||||
private List<String> downloads;
|
||||
private List<String> views;
|
||||
|
||||
@JsonProperty("total_downloads")
|
||||
private String totalDownloads;
|
||||
|
||||
@JsonProperty("total_views")
|
||||
private String totalViews;
|
||||
|
||||
@JsonProperty("total_openaire_downloads")
|
||||
private String totalOpenAIREDownloads;
|
||||
|
||||
@JsonProperty("total_openaire_views")
|
||||
private String totalOpenAIREViews;
|
||||
|
||||
@JsonProperty("pageviews")
|
||||
private String pageViews;
|
||||
|
||||
public MetricsNumbers() {
|
||||
}
|
||||
|
||||
public MetricsNumbers(List<String> downloads, List<String> views, String totalDownloads, String totalViews,
|
||||
String totalOpenAIREDownloads, String totalOpenAIREViews, String pageViews) {
|
||||
this.downloads = downloads;
|
||||
this.views = views;
|
||||
this.totalDownloads = totalDownloads;
|
||||
this.totalViews = totalViews;
|
||||
this.totalOpenAIREDownloads = totalOpenAIREDownloads;
|
||||
this.totalOpenAIREViews = totalOpenAIREViews;
|
||||
this.pageViews = pageViews;
|
||||
}
|
||||
|
||||
public List<String> getDownloads() {
|
||||
return downloads;
|
||||
}
|
||||
|
||||
public void setDownloads(List<String> downloads) {
|
||||
this.downloads = downloads;
|
||||
}
|
||||
|
||||
public List<String> getViews() {
|
||||
return views;
|
||||
}
|
||||
|
||||
public void setViews(List<String> views) {
|
||||
this.views = views;
|
||||
}
|
||||
|
||||
public String getTotalDownloads() {
|
||||
return totalDownloads;
|
||||
}
|
||||
|
||||
public void setTotalDownloads(String totalDownloads) {
|
||||
this.totalDownloads = totalDownloads;
|
||||
}
|
||||
|
||||
public String getTotalViews() {
|
||||
return totalViews;
|
||||
}
|
||||
|
||||
public void setTotalViews(String totalViews) {
|
||||
this.totalViews = totalViews;
|
||||
}
|
||||
|
||||
public String getTotalOpenAIREDownloads() {
|
||||
return totalOpenAIREDownloads;
|
||||
}
|
||||
|
||||
public void setTotalOpenAIREDownloads(String totalOpenAIREDownloads) {
|
||||
this.totalOpenAIREDownloads = totalOpenAIREDownloads;
|
||||
}
|
||||
|
||||
public String getTotalOpenAIREViews() {
|
||||
return totalOpenAIREViews;
|
||||
}
|
||||
|
||||
public void setTotalOpenAIREViews(String totalOpenAIREViews) {
|
||||
this.totalOpenAIREViews = totalOpenAIREViews;
|
||||
}
|
||||
|
||||
public String getPageViews() {
|
||||
return pageViews;
|
||||
}
|
||||
|
||||
public void setPageViews(String pageViews) {
|
||||
this.pageViews = pageViews;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 7/12/15.
|
||||
*/
|
||||
public class RepositoryServiceException extends Exception implements IsSerializable {
|
||||
|
||||
public enum ErrorCode implements IsSerializable {
|
||||
REPOSITORY_ALREADY_EXISTS,
|
||||
SQL_ERROR,
|
||||
NOT_ACTIVATED,
|
||||
ACTIVATION_ERROR,
|
||||
LDAP_ERROR,
|
||||
MAIL_ALREADY_EXISTS,
|
||||
GENERAL_ERROR,
|
||||
ALREADY_ACTIVATED,
|
||||
INVALID_EMAIL_FORMAT,
|
||||
NO_REPOS_FOR_THIS_COUNTRY, REPOSITORY_NOT_EXISTS, INCORRECT_CAPTCHA
|
||||
}
|
||||
|
||||
private ErrorCode errorCode = null;
|
||||
|
||||
public RepositoryServiceException() {
|
||||
}
|
||||
|
||||
public RepositoryServiceException(ErrorCode errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public RepositoryServiceException(String message, Throwable cause, ErrorCode errorCode) {
|
||||
super(message, cause);
|
||||
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public RepositoryServiceException(String message, ErrorCode errorCode) {
|
||||
super(message);
|
||||
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public RepositoryServiceException(Throwable cause, ErrorCode errorCode) {
|
||||
super(cause);
|
||||
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public ErrorCode getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by panagiotis on 15/1/2018.
|
||||
*/
|
||||
public class Term implements IsSerializable {
|
||||
|
||||
private String englishName;
|
||||
private String nativeName;
|
||||
private String encoding;
|
||||
private String code;
|
||||
|
||||
public Term(String englishName, String nativeName, String encoding, String code) {
|
||||
this.englishName = englishName;
|
||||
this.nativeName = nativeName;
|
||||
this.encoding = encoding;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getEnglishName() {
|
||||
return englishName;
|
||||
}
|
||||
|
||||
public void setEnglishName(String englishName) {
|
||||
this.englishName = englishName;
|
||||
}
|
||||
|
||||
public String getNativeName() {
|
||||
return nativeName;
|
||||
}
|
||||
|
||||
public void setNativeName(String nativeName) {
|
||||
this.nativeName = nativeName;
|
||||
}
|
||||
|
||||
public String getEncoding() {
|
||||
return encoding;
|
||||
}
|
||||
|
||||
public void setEncoding(String encoding) {
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
public class Timezone implements IsSerializable {
|
||||
private String name;
|
||||
private double offset;
|
||||
|
||||
public Timezone(){
|
||||
}
|
||||
|
||||
public Timezone(String name, double offset) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.offset = offset;
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefania on 3/8/16.
|
||||
*/
|
||||
public class Triple<K, V, L> extends Tuple<K, V> implements IsSerializable {
|
||||
|
||||
private L third;
|
||||
|
||||
public Triple() {
|
||||
}
|
||||
|
||||
public Triple(K first, V second, L third) {
|
||||
super(first, second);
|
||||
this.third = third;
|
||||
}
|
||||
|
||||
public L getThird() {
|
||||
return third;
|
||||
}
|
||||
|
||||
public void setThird(L third) {
|
||||
this.third = third;
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefania on 12/18/15.
|
||||
*/
|
||||
public class Tuple<K, V> implements IsSerializable {
|
||||
|
||||
private K first;
|
||||
private V second;
|
||||
|
||||
public Tuple() {
|
||||
}
|
||||
|
||||
public Tuple(K first, V second) {
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
}
|
||||
|
||||
public K getFirst() {
|
||||
return first;
|
||||
}
|
||||
|
||||
public void setFirst(K first) {
|
||||
this.first = first;
|
||||
}
|
||||
|
||||
public V getSecond() {
|
||||
return second;
|
||||
}
|
||||
|
||||
public void setSecond(V second) {
|
||||
this.second = second;
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 7/12/15.
|
||||
*/
|
||||
public class UserAccessException extends Exception implements IsSerializable {
|
||||
|
||||
public enum ErrorCode implements IsSerializable {
|
||||
USER_ALREADY_EXISTS,
|
||||
SQL_ERROR,
|
||||
INVALID_USERNAME,
|
||||
INVALID_PASSWORD,
|
||||
NOT_ACTIVATED,
|
||||
ACTIVATION_ERROR,
|
||||
LDAP_ERROR,
|
||||
USERNAME_ALREADY_EXISTS, MAIL_ALREADY_EXISTS, GENERAL_ERROR, ALREADY_ACTIVATED, INVALID_EMAIL_FORMAT, WRONG_SECURITY_CODE, INCORRECT_CAPTCHA
|
||||
}
|
||||
|
||||
private ErrorCode errorCode = null;
|
||||
|
||||
public UserAccessException() {
|
||||
}
|
||||
|
||||
public UserAccessException(ErrorCode errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public UserAccessException(String message, Throwable cause, ErrorCode errorCode) {
|
||||
super(message, cause);
|
||||
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public UserAccessException(String message, ErrorCode errorCode) {
|
||||
super(message);
|
||||
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public UserAccessException(Throwable cause, ErrorCode errorCode) {
|
||||
super(cause);
|
||||
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public ErrorCode getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by nikonas on 7/12/15.
|
||||
*/
|
||||
public class ValidationServiceException extends Exception implements IsSerializable {
|
||||
|
||||
public enum ErrorCode implements IsSerializable {
|
||||
NO_ADMIN_EMAILS,
|
||||
NOT_VALID_BASEURL,
|
||||
GENERAL_ERROR, NOT_VALID_SET
|
||||
}
|
||||
|
||||
private ErrorCode errorCode = null;
|
||||
|
||||
public ValidationServiceException() {
|
||||
}
|
||||
|
||||
public ValidationServiceException(ErrorCode errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public ValidationServiceException(String message, Throwable cause, ErrorCode errorCode) {
|
||||
super(message, cause);
|
||||
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public ValidationServiceException(String message, ErrorCode errorCode) {
|
||||
super(message);
|
||||
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public ValidationServiceException(Throwable cause, ErrorCode errorCode) {
|
||||
super(cause);
|
||||
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public ErrorCode getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
|
||||
/**
|
||||
* Created by stefania on 2/10/16.
|
||||
*/
|
||||
public class ValidationState extends WizardState implements IsSerializable {
|
||||
|
||||
private JobForValidation jobForValidation = new JobForValidation();
|
||||
|
||||
public JobForValidation getJobForValidation() {
|
||||
return jobForValidation;
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefania on 3/8/16.
|
||||
*/
|
||||
public class Vocabulary implements IsSerializable {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
|
||||
public Vocabulary() {
|
||||
}
|
||||
|
||||
public Vocabulary(String id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefania on 2/10/16.
|
||||
*/
|
||||
public class WizardState implements IsSerializable {
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AdvQueryObject implements IsSerializable {
|
||||
|
||||
private String datasource = "";
|
||||
private String topic = "";
|
||||
private List<String> titles = new ArrayList<>();
|
||||
private List<String> subjects = new ArrayList<>();
|
||||
private List<String> authors = new ArrayList<>();
|
||||
private List<Range> dates = new ArrayList<>();
|
||||
private Range trust = new Range("0", "1");
|
||||
|
||||
private long page = 0;
|
||||
|
||||
public AdvQueryObject() {
|
||||
}
|
||||
|
||||
public AdvQueryObject(String datasource, String topic, List<String> titles, List<String> subjects, List<String> authors,
|
||||
List<Range> dates, Range trust, long page) {
|
||||
this.datasource = datasource;
|
||||
this.topic = topic;
|
||||
this.titles = titles;
|
||||
this.subjects = subjects;
|
||||
this.authors = authors;
|
||||
this.dates = dates;
|
||||
this.trust = trust;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public String getDatasource() {
|
||||
return datasource;
|
||||
}
|
||||
|
||||
public void setDatasource(String datasource) {
|
||||
this.datasource = datasource;
|
||||
}
|
||||
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
|
||||
public void setTopic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
|
||||
public List<String> getTitles() {
|
||||
return titles;
|
||||
}
|
||||
|
||||
public void setTitles(List<String> titles) {
|
||||
this.titles = titles;
|
||||
}
|
||||
|
||||
public List<String> getSubjects() {
|
||||
return subjects;
|
||||
}
|
||||
|
||||
public void setSubjects(List<String> subjects) {
|
||||
this.subjects = subjects;
|
||||
}
|
||||
|
||||
public List<String> getAuthors() {
|
||||
return authors;
|
||||
}
|
||||
|
||||
public void setAuthors(List<String> authors) {
|
||||
this.authors = authors;
|
||||
}
|
||||
|
||||
public List<Range> getDates() {
|
||||
return dates;
|
||||
}
|
||||
|
||||
public void setDates(List<Range> dates) {
|
||||
this.dates = dates;
|
||||
}
|
||||
|
||||
public Range getTrust() {
|
||||
return trust;
|
||||
}
|
||||
|
||||
public void setTrust(Range trust) {
|
||||
this.trust = trust;
|
||||
}
|
||||
|
||||
public long getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(long page) {
|
||||
this.page = page;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 26/10/2016.
|
||||
*/
|
||||
public class BrowseEntry implements Comparable<BrowseEntry>, IsSerializable{
|
||||
|
||||
private String value;
|
||||
private Long size;
|
||||
|
||||
public BrowseEntry() {
|
||||
}
|
||||
|
||||
public BrowseEntry(final String value, final Long size) {
|
||||
this.value = value;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(Long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(final BrowseEntry bv) {
|
||||
return Long.compare(getSize(), bv.getSize());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 17/3/2017.
|
||||
*/
|
||||
public enum ConditionOperator implements IsSerializable {
|
||||
EXACT, MATCH_ANY, MATCH_ALL, RANGE
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 17/3/2017.
|
||||
*/
|
||||
public class ConditionParams implements IsSerializable {
|
||||
|
||||
private String value;
|
||||
private String otherValue;
|
||||
|
||||
public ConditionParams() {
|
||||
}
|
||||
|
||||
public ConditionParams(final String value, final String otherValue) {
|
||||
this.value = value;
|
||||
this.otherValue = otherValue;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(final String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getOtherValue() {
|
||||
return this.otherValue;
|
||||
}
|
||||
|
||||
public void setOtherValue(final String otherValue) {
|
||||
this.otherValue = otherValue;
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Dataset implements IsSerializable {
|
||||
|
||||
private List<String> titles;
|
||||
|
||||
private List<String> collectedFrom;
|
||||
|
||||
private List<Pid> pids;
|
||||
|
||||
private List<Instance> instances;
|
||||
|
||||
public Dataset() {
|
||||
}
|
||||
|
||||
public Dataset(final List<String> titles, final List<String> collectedFrom, final List<Pid> pids, final List<Instance> instances) {
|
||||
this.titles = titles;
|
||||
this.collectedFrom = collectedFrom;
|
||||
this.pids = pids;
|
||||
this.instances = instances;
|
||||
}
|
||||
|
||||
public List<String> getTitles() {
|
||||
return titles;
|
||||
}
|
||||
|
||||
public void setTitles(List<String> titles) {
|
||||
this.titles = titles;
|
||||
}
|
||||
|
||||
public List<String> getCollectedFrom() {
|
||||
return collectedFrom;
|
||||
}
|
||||
|
||||
public void setCollectedFrom(List<String> collectedFrom) {
|
||||
this.collectedFrom = collectedFrom;
|
||||
}
|
||||
|
||||
public List<Pid> getPids() {
|
||||
return pids;
|
||||
}
|
||||
|
||||
public void setPids(List<Pid> pids) {
|
||||
this.pids = pids;
|
||||
}
|
||||
|
||||
public List<Instance> getInstances() {
|
||||
return instances;
|
||||
}
|
||||
|
||||
public void setInstances(List<Instance> instances) {
|
||||
this.instances = instances;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
import eu.dnetlib.repo.manager.shared.Tuple;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 31/10/2016.
|
||||
*/
|
||||
public class DatasourcesBroker implements IsSerializable {
|
||||
|
||||
private List<Tuple<BrowseEntry, String>> datasourcesOfUser;
|
||||
private List<Tuple<BrowseEntry, String>> sharedDatasources;
|
||||
private List<Tuple<BrowseEntry, String>> datasourcesOfOthers;
|
||||
|
||||
public List<Tuple<BrowseEntry, String>> getDatasourcesOfUser() {
|
||||
return datasourcesOfUser;
|
||||
}
|
||||
|
||||
public void setDatasourcesOfUser(List<Tuple<BrowseEntry, String>> datasourcesOfUser) {
|
||||
this.datasourcesOfUser = datasourcesOfUser;
|
||||
}
|
||||
|
||||
public List<Tuple<BrowseEntry, String>> getSharedDatasources() {
|
||||
return sharedDatasources;
|
||||
}
|
||||
|
||||
public void setSharedDatasources(List<Tuple<BrowseEntry, String>> sharedDatasources) {
|
||||
this.sharedDatasources = sharedDatasources;
|
||||
}
|
||||
|
||||
public List<Tuple<BrowseEntry, String>> getDatasourcesOfOthers() {
|
||||
return datasourcesOfOthers;
|
||||
}
|
||||
|
||||
public void setDatasourcesOfOthers(List<Tuple<BrowseEntry, String>> datasourcesOfOthers) {
|
||||
this.datasourcesOfOthers = datasourcesOfOthers;
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 26/10/2016.
|
||||
*/
|
||||
public class EventsPage implements IsSerializable{
|
||||
|
||||
private String datasource;
|
||||
private String topic;
|
||||
private long currPage;
|
||||
private long totalPages;
|
||||
private long total;
|
||||
private List<OpenAireEventPayload> values;
|
||||
|
||||
public EventsPage() {
|
||||
|
||||
}
|
||||
public EventsPage(final String datasource, final String topic, final long currPage, final long totalPages, final long total,
|
||||
final List<OpenAireEventPayload> values) {
|
||||
this.datasource = datasource;
|
||||
this.topic = topic;
|
||||
this.currPage = currPage;
|
||||
this.totalPages = totalPages;
|
||||
this.total = total;
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public String getDatasource() {
|
||||
return datasource;
|
||||
}
|
||||
|
||||
public void setDatasource(String datasource) {
|
||||
this.datasource = datasource;
|
||||
}
|
||||
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
|
||||
public void setTopic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
|
||||
public long getCurrPage() {
|
||||
return currPage;
|
||||
}
|
||||
|
||||
public void setCurrPage(long currPage) {
|
||||
this.currPage = currPage;
|
||||
}
|
||||
|
||||
public long getTotalPages() {
|
||||
return totalPages;
|
||||
}
|
||||
|
||||
public void setTotalPages(long totalPages) {
|
||||
this.totalPages = totalPages;
|
||||
}
|
||||
|
||||
public long getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(long total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public List<OpenAireEventPayload> getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(List<OpenAireEventPayload> values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by claudio on 22/07/16.
|
||||
*/
|
||||
public class ExternalReference implements IsSerializable {
|
||||
|
||||
private String url;
|
||||
|
||||
private String sitename;
|
||||
|
||||
private String type;
|
||||
|
||||
private String refidentifier;
|
||||
|
||||
public ExternalReference() {
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getSitename() {
|
||||
return sitename;
|
||||
}
|
||||
|
||||
public void setSitename(String sitename) {
|
||||
this.sitename = sitename;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getRefidentifier() {
|
||||
return refidentifier;
|
||||
}
|
||||
|
||||
public void setRefidentifier(String refidentifier) {
|
||||
this.refidentifier = refidentifier;
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by claudio on 22/07/16.
|
||||
*/
|
||||
public class Instance implements IsSerializable {
|
||||
|
||||
private String url;
|
||||
|
||||
private String license;
|
||||
|
||||
private String hostedby;
|
||||
|
||||
private String instancetype;
|
||||
|
||||
public Instance() {
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getLicense() {
|
||||
return license;
|
||||
}
|
||||
|
||||
public void setLicense(String license) {
|
||||
this.license = license;
|
||||
}
|
||||
|
||||
public String getHostedby() {
|
||||
return hostedby;
|
||||
}
|
||||
|
||||
public void setHostedby(String hostedby) {
|
||||
this.hostedby = hostedby;
|
||||
}
|
||||
|
||||
public String getInstancetype() {
|
||||
return instancetype;
|
||||
}
|
||||
|
||||
public void setInstancetype(String instancetype) {
|
||||
this.instancetype = instancetype;
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by claudio on 22/07/16.
|
||||
*/
|
||||
public class Journal implements IsSerializable {
|
||||
|
||||
private String name;
|
||||
|
||||
private String issn;
|
||||
|
||||
private String eissn;
|
||||
|
||||
private String lissn;
|
||||
|
||||
public Journal() {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getIssn() {
|
||||
return issn;
|
||||
}
|
||||
|
||||
public void setIssn(String issn) {
|
||||
this.issn = issn;
|
||||
}
|
||||
|
||||
public String getEissn() {
|
||||
return eissn;
|
||||
}
|
||||
|
||||
public void setEissn(String eissn) {
|
||||
this.eissn = eissn;
|
||||
}
|
||||
|
||||
public String getLissn() {
|
||||
return lissn;
|
||||
}
|
||||
|
||||
public void setLissn(String lissn) {
|
||||
this.lissn = lissn;
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 17/3/2017.
|
||||
*/
|
||||
public class MapConditions implements IsSerializable {
|
||||
|
||||
private String field;
|
||||
private MapValueType fieldType;
|
||||
private ConditionOperator operator;
|
||||
private List<ConditionParams> listParams = new ArrayList<>();
|
||||
|
||||
public MapConditions() {
|
||||
}
|
||||
|
||||
public String getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public void setField(String field) {
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
public MapValueType getFieldType() {
|
||||
return fieldType;
|
||||
}
|
||||
|
||||
public void setFieldType(MapValueType fieldType) {
|
||||
this.fieldType = fieldType;
|
||||
}
|
||||
|
||||
public ConditionOperator getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(ConditionOperator operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public List<ConditionParams> getListParams() {
|
||||
return listParams;
|
||||
}
|
||||
|
||||
public void setListParams(List<ConditionParams> listParams) {
|
||||
this.listParams = listParams;
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 17/3/2017.
|
||||
*/
|
||||
public enum MapValueType implements IsSerializable {
|
||||
STRING, INTEGER, FLOAT, DATE, BOOLEAN, LIST_STRING, LIST_INTEGER, LIST_FLOAT, LIST_DATE, LIST_BOOLEAN;
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 10-Mar-17.
|
||||
*/
|
||||
public enum NotificationFrequency implements IsSerializable {
|
||||
never, realtime, daily, weekly, monthly
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 10-Mar-17.
|
||||
*/
|
||||
public enum NotificationMode implements IsSerializable {
|
||||
MOCK, EMAIL
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by claudio on 11/07/16.
|
||||
*/
|
||||
public class OpenAireEventPayload implements IsSerializable {
|
||||
|
||||
private Publication publication;
|
||||
|
||||
private Publication highlight;
|
||||
|
||||
private Provenance provenance;
|
||||
|
||||
private float trust;
|
||||
|
||||
public OpenAireEventPayload() {
|
||||
}
|
||||
|
||||
public Publication getPublication() {
|
||||
return publication;
|
||||
}
|
||||
|
||||
public void setPublication(Publication publication) {
|
||||
this.publication = publication;
|
||||
}
|
||||
|
||||
public Publication getHighlight() {
|
||||
return highlight;
|
||||
}
|
||||
|
||||
public void setHighlight(Publication highlight) {
|
||||
this.highlight = highlight;
|
||||
}
|
||||
|
||||
public Provenance getProvenance() {
|
||||
return provenance;
|
||||
}
|
||||
|
||||
public void setProvenance(Provenance provenance) {
|
||||
this.provenance = provenance;
|
||||
}
|
||||
|
||||
public float getTrust() {
|
||||
return trust;
|
||||
}
|
||||
|
||||
public void setTrust(float trust) {
|
||||
this.trust = trust;
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by stefanos on 10-Mar-17.
|
||||
*/
|
||||
|
||||
public class OpenaireSubscription implements IsSerializable {
|
||||
|
||||
private String subscriber;
|
||||
private NotificationFrequency frequency;
|
||||
private NotificationMode mode;
|
||||
private AdvQueryObject query;
|
||||
|
||||
public OpenaireSubscription() {
|
||||
}
|
||||
|
||||
public OpenaireSubscription(final String subscriber, final NotificationFrequency frequency, final
|
||||
NotificationMode mode,
|
||||
final AdvQueryObject query) {
|
||||
this.subscriber = subscriber;
|
||||
this.frequency = frequency;
|
||||
this.mode = mode;
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
public String getSubscriber() {
|
||||
return this.subscriber;
|
||||
}
|
||||
|
||||
public void setSubscriber(final String subscriber) {
|
||||
this.subscriber = subscriber;
|
||||
}
|
||||
|
||||
public NotificationFrequency getFrequency() {
|
||||
return this.frequency;
|
||||
}
|
||||
|
||||
public void setFrequency(final NotificationFrequency frequency) {
|
||||
this.frequency = frequency;
|
||||
}
|
||||
|
||||
public NotificationMode getMode() {
|
||||
return this.mode;
|
||||
}
|
||||
|
||||
public void setMode(final NotificationMode mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public AdvQueryObject getQuery() {
|
||||
return this.query;
|
||||
}
|
||||
|
||||
public void setQuery(final AdvQueryObject query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package eu.dnetlib.repo.manager.shared.broker;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* Created by claudio on 22/07/16.
|
||||
*/
|
||||
public class Pid implements IsSerializable {
|
||||
|
||||
private String value;
|
||||
|
||||
private String type;
|
||||
|
||||
public Pid() {
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue