Compare commits
15 Commits
master
...
feature/in
Author | SHA1 | Date |
---|---|---|
Konstantinos Spyrou | ce2a58ebac | |
Konstantinos Spyrou | 081bb887f3 | |
Konstantinos Spyrou | 829f5fa392 | |
Konstantinos Spyrou | 768004de62 | |
Konstantinos Spyrou | 5010b8d04f | |
Konstantinos Spyrou | c5e9c7ea37 | |
Konstantinos Spyrou | 68ccee11f2 | |
Konstantinos Spyrou | efdeb01b4e | |
Konstantinos Spyrou | 6a4c939df2 | |
Konstantinos Spyrou | 9d79316040 | |
Konstantinos Spyrou | 77437fa03c | |
Konstantinos Spyrou | b42f7585f6 | |
Konstantinos Spyrou | 684b094f36 | |
Konstantinos Spyrou | bfb9d865cb | |
Konstantinos Spyrou | de76e89349 |
186
pom.xml
186
pom.xml
|
@ -17,14 +17,14 @@
|
|||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<spring.boot.version>2.7.18</spring.boot.version>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -32,54 +32,49 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-security</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jdbc</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-devtools</artifactId>-->
|
||||
<!-- <optional>true</optional>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
|
@ -112,46 +107,50 @@
|
|||
<version>1.12.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- for Validator Service -->
|
||||
<!-- JAX-WS API -->
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>uoa-clients</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt-user</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<groupId>javax.xml.ws</groupId>
|
||||
<artifactId>jaxws-api</artifactId>
|
||||
<version>2.3.1</version> <!-- or the latest version -->
|
||||
</dependency>
|
||||
|
||||
<!-- JAX-WS Runtime Implementation (e.g., Metro) -->
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.ws</groupId>
|
||||
<artifactId>jaxws-rt</artifactId>
|
||||
<version>2.3.7</version> <!-- or the latest version -->
|
||||
</dependency>
|
||||
<!-- for Validator Service -->
|
||||
|
||||
<!-- Needed to remove dependency to dnet-runtime -->
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-core</artifactId>
|
||||
<version>3.1.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>dnet-runtime</artifactId>
|
||||
<version>1.0.2-SNAPSHOT</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-bindings-soap</artifactId>
|
||||
<version>3.1.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-transports-http</artifactId>
|
||||
<version>3.1.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||
<version>3.1.5</version>
|
||||
</dependency>
|
||||
<!-- Needed to remove dependency to dnet-runtime -->
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>uoa-hcm</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
|
@ -176,16 +175,16 @@
|
|||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cglib</groupId>
|
||||
<artifactId>cglib-nodep</artifactId>
|
||||
<version>3.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.16.0</version>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>4.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cglib</groupId>-->
|
||||
<!-- <artifactId>cglib-nodep</artifactId>-->
|
||||
<!-- <version>3.3.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>se.kb</groupId>
|
||||
|
@ -193,27 +192,12 @@
|
|||
<version>[0.6b1,)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- TODO - Do we need this? -->
|
||||
<dependency>
|
||||
<groupId>xalan</groupId>
|
||||
<artifactId>xalan</artifactId>
|
||||
<version>2.7.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-client</artifactId>
|
||||
<version>2.42</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- TODO - Do we need this? We already have: "com.google.code.gson:gson" -->
|
||||
<dependency>
|
||||
<groupId>org.aksw.gson</groupId>
|
||||
<artifactId>gson-utils-core</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
<!-- <!– TODO - Do we need this? –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>xalan</groupId>-->
|
||||
<!-- <artifactId>xalan</artifactId>-->
|
||||
<!-- <version>2.7.3</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
|
@ -234,12 +218,6 @@
|
|||
<version>42.7.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mitre</groupId>
|
||||
<artifactId>openid-connect-client</artifactId>
|
||||
|
@ -277,24 +255,7 @@
|
|||
<version>2.10.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.thetransactioncompany</groupId>
|
||||
<artifactId>cors-filter</artifactId>
|
||||
<version>3.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
|
||||
<dependency>
|
||||
<groupId>javax.xml.ws</groupId>
|
||||
<artifactId>jaxws-api</artifactId>
|
||||
<version>2.3.1</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>
|
||||
|
@ -320,13 +281,7 @@
|
|||
<dependency>
|
||||
<groupId>org.eurocris</groupId>
|
||||
<artifactId>openaire-cris-validator</artifactId>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <groupId>org.apache.logging.log4j</groupId>-->
|
||||
<!-- <artifactId>log4j-1.2-api</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<version>2.0.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
@ -334,13 +289,13 @@
|
|||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-bom</artifactId>
|
||||
<version>2021.2.3</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.session</groupId>-->
|
||||
<!-- <artifactId>spring-session-bom</artifactId>-->
|
||||
<!-- <version>2021.2.3</version>-->
|
||||
<!-- <type>pom</type>-->
|
||||
<!-- <scope>import</scope>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
@ -371,7 +326,6 @@
|
|||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package eu.dnetlib.repo.manager.clients.ws;
|
||||
|
||||
import eu.dnetlib.api.DriverService;
|
||||
import eu.dnetlib.domain.ServiceIdentity;
|
||||
import eu.dnetlib.domain.enabling.Notification;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public abstract class BaseDriverWebService<S extends DriverService> implements
|
||||
DriverWebService<S> {
|
||||
private static Logger logger = Logger.getLogger(BaseDriverWebService.class);
|
||||
|
||||
protected S service = null;
|
||||
|
||||
public void setService(S service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String identify() {
|
||||
ServiceIdentity identity = service.identify();
|
||||
|
||||
if (identity != null)
|
||||
return service.identify().toString();
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void notify(String subscriptionId, String topic, String isId,
|
||||
String message) {
|
||||
logger.debug("Notification received: " + topic + ", message: "
|
||||
+ message);
|
||||
|
||||
try {
|
||||
Notification notification = new Notification(subscriptionId,
|
||||
message, topic, isId);
|
||||
|
||||
service.notify(notification);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error creating notification", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package eu.dnetlib.repo.manager.clients.ws;
|
||||
|
||||
import eu.dnetlib.api.DriverService;
|
||||
import eu.dnetlib.api.DriverServiceException;
|
||||
import eu.dnetlib.domain.ServiceIdentity;
|
||||
import eu.dnetlib.domain.enabling.Notification;
|
||||
import eu.dnetlib.utils.ServiceIdentityFactory;
|
||||
|
||||
public abstract class BaseWebServiceClient<WS extends DriverWebService<? extends DriverService>>
|
||||
implements DriverService {
|
||||
|
||||
protected WS webService = null;
|
||||
|
||||
@Override
|
||||
public final ServiceIdentity identify() {
|
||||
String identity = webService.identify();
|
||||
|
||||
if (identity != null)
|
||||
return ServiceIdentityFactory.parseIdentity(webService.identify());
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void notify(Notification notification)
|
||||
throws DriverServiceException {
|
||||
try {
|
||||
webService.notify(
|
||||
notification.getSubscriptionId(),
|
||||
notification.getTopic(),
|
||||
notification.getIsId(),
|
||||
notification.getMessage());
|
||||
} catch (Exception e) {
|
||||
throw new DriverServiceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public final WS getWebService() {
|
||||
return webService;
|
||||
}
|
||||
|
||||
public final void setWebService(WS webService) {
|
||||
this.webService = webService;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final void setWebService(Object webService) {
|
||||
this.webService = (WS) webService;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package eu.dnetlib.repo.manager.clients.ws;
|
||||
|
||||
import eu.dnetlib.api.DriverService;
|
||||
import eu.dnetlib.api.DriverServiceEndpoint;
|
||||
import eu.dnetlib.common.rmi.BaseService;
|
||||
|
||||
import javax.jws.WebService;
|
||||
|
||||
@WebService
|
||||
public interface DriverWebService<S extends DriverService> extends BaseService,
|
||||
DriverServiceEndpoint<S> {
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package eu.dnetlib.repo.manager.clients.ws.validator;
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorService;
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.repo.manager.clients.ws.DriverWebService;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
|
||||
import javax.jws.WebMethod;
|
||||
import javax.jws.WebParam;
|
||||
import javax.jws.WebService;
|
||||
import java.util.List;
|
||||
|
||||
@WebService (targetNamespace ="http://services.dnetlib.eu/")
|
||||
public interface ValidatorWebService extends DriverWebService<ValidatorService> {
|
||||
|
||||
@WebMethod(operationName = "getStoredJob")
|
||||
StoredJob getStoredJob(@WebParam(name = "jobId") int jobId, @WebParam(name = "groupBy") String groupBy) throws ValidatorServiceException;
|
||||
|
||||
@WebMethod(operationName = "getJobSummary")
|
||||
List<StoredJob> getJobSummary(@WebParam(name = "baseUrl") List<String> baseUrl, @WebParam(name = "limit") int limit) throws ValidatorServiceException;
|
||||
|
||||
@WebMethod(operationName = "getStoredJobs")
|
||||
List<StoredJob> getStoredJobs(@WebParam(name = "userMail") String userMail, @WebParam(name = "jobType") String jobType, @WebParam(name = "offset") Integer offset, @WebParam(name = "limit") Integer limit, @WebParam(name = "dateFrom") String dateFrom, @WebParam(name = "dateTo") String dateTo) throws ValidatorServiceException;
|
||||
|
||||
@WebMethod(operationName = "getStoredJobsTotalNumber")
|
||||
int getStoredJobsTotalNumber(@WebParam(name = "userMail") String userMail, @WebParam(name = "jobType") String jobType) throws ValidatorServiceException;
|
||||
|
||||
@WebMethod(operationName = "getStoredJobsNew")
|
||||
List<StoredJob> getStoredJobsNew(@WebParam(name = "userMail") String userMail, @WebParam(name = "jobType") String jobType, @WebParam(name = "offset") Integer offset, @WebParam(name = "limit") Integer limit, @WebParam(name = "dateFrom") String dateFrom, @WebParam(name = "dateTo") String dateTo, @WebParam(name = "jobStatus") String jobStatus) throws ValidatorServiceException;
|
||||
|
||||
@WebMethod(operationName = "getStoredJobsTotalNumberNew")
|
||||
int getStoredJobsTotalNumberNew(@WebParam(name = "userMail") String userMail, @WebParam(name = "jobType") String jobType, @WebParam(name = "jobStatus") String jobStatus) throws ValidatorServiceException;
|
||||
|
||||
@WebMethod(operationName = "getRuleSets")
|
||||
List<RuleSet> getRuleSets() throws ValidatorServiceException;
|
||||
|
||||
@WebMethod(operationName = "submitValidationJob")
|
||||
void submitValidationJob(@WebParam(name = "job")JobForValidation job) throws ValidatorServiceException;
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package eu.dnetlib.repo.manager.clients.ws.validator;
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorService;
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.repo.manager.clients.ws.BaseWebServiceClient;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ValidatorWebServiceClient extends
|
||||
BaseWebServiceClient<ValidatorWebService> implements ValidatorService {
|
||||
|
||||
private Logger logger = Logger.getLogger(ValidatorWebServiceClient.class);
|
||||
|
||||
@Override
|
||||
public StoredJob getStoredJob(int jobId, String groupBy)
|
||||
throws ValidatorServiceException {
|
||||
return this.webService.getStoredJob(jobId, groupBy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoredJob> getJobSummary(List<String> baseUrl, int size)
|
||||
throws ValidatorServiceException {
|
||||
return this.webService.getJobSummary(baseUrl, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoredJob> getStoredJobs(String userMail, String jobType, Integer offset, Integer limit, String dateFrom, String dateTo)
|
||||
throws ValidatorServiceException {
|
||||
return this.webService.getStoredJobs(userMail, jobType, offset, limit, dateFrom, dateTo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoredJob> getStoredJobsNew(String userMail, String jobType, Integer offset, Integer limit, String dateFrom, String dateTo, String jobStatus)
|
||||
throws ValidatorServiceException {
|
||||
return this.webService.getStoredJobsNew(userMail, jobType, offset, limit, dateFrom, dateTo, jobStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredJobsTotalNumber(String userMail, String jobType)
|
||||
throws ValidatorServiceException {
|
||||
return this.webService.getStoredJobsTotalNumber(userMail, jobType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredJobsTotalNumberNew(String userMail, String jobType, String jobStatus)
|
||||
throws ValidatorServiceException {
|
||||
return this.webService.getStoredJobsTotalNumberNew(userMail, jobType, jobStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RuleSet> getRuleSets() throws ValidatorServiceException {
|
||||
return this.webService.getRuleSets();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitValidationJob(JobForValidation job)
|
||||
throws ValidatorServiceException {
|
||||
this.webService.submitValidationJob(job);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package eu.dnetlib.repo.manager.clients.ws.validator;
|
||||
|
||||
import eu.dnetlib.api.functionality.ValidatorService;
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.repo.manager.clients.ws.BaseDriverWebService;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
||||
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
||||
|
||||
import javax.jws.WebService;
|
||||
import java.util.List;
|
||||
|
||||
@WebService(
|
||||
targetNamespace ="http://services.dnetlib.eu/",
|
||||
serviceName = "ValidatorWebService",
|
||||
endpointInterface = "eu.dnetlib.repo.manager.clients.ws.validator.ValidatorWebService")
|
||||
public class ValidatorWebServiceImpl
|
||||
extends BaseDriverWebService<ValidatorService>
|
||||
implements ValidatorWebService {
|
||||
|
||||
@Override
|
||||
public StoredJob getStoredJob(int jobId, String groupBy)
|
||||
throws ValidatorServiceException {
|
||||
return service.getStoredJob(jobId, groupBy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoredJob> getJobSummary(List<String> baseUrl, int limit) throws ValidatorServiceException {
|
||||
return service.getJobSummary(baseUrl,limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoredJob> getStoredJobs(String userMail, String jobType,
|
||||
Integer offset, Integer limit, String dateFrom, String dateTo) throws ValidatorServiceException {
|
||||
return service.getStoredJobs(userMail, jobType, offset, limit, dateFrom, dateTo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoredJob> getStoredJobsNew(String userMail, String jobType,
|
||||
Integer offset, Integer limit, String dateFrom, String dateTo, String jobStatus) throws ValidatorServiceException {
|
||||
return service.getStoredJobsNew(userMail, jobType, offset, limit, dateFrom, dateTo, jobStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredJobsTotalNumber(String userMail, String jobType) throws ValidatorServiceException {
|
||||
return service.getStoredJobsTotalNumber(userMail, jobType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredJobsTotalNumberNew(String userMail, String jobType, String jobStatus) throws ValidatorServiceException {
|
||||
return service.getStoredJobsTotalNumberNew(userMail, jobType, jobStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RuleSet> getRuleSets() throws ValidatorServiceException {
|
||||
return service.getRuleSets();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitValidationJob(JobForValidation job)
|
||||
throws ValidatorServiceException {
|
||||
service.submitValidationJob(job);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,19 +1,13 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import eu.dnetlib.api.enabling.ISLookUpService;
|
||||
import eu.dnetlib.api.functionality.ValidatorService;
|
||||
import eu.dnetlib.clients.enabling.islookup.ws.ISLookUpClient;
|
||||
import eu.dnetlib.clients.functionality.validator.ws.ValidatorWebService;
|
||||
import eu.dnetlib.clients.functionality.validator.ws.ValidatorWebServiceClient;
|
||||
import eu.dnetlib.domain.enabling.Vocabulary;
|
||||
import gr.uoa.di.driver.enabling.ISLookUp;
|
||||
import gr.uoa.di.driver.enabling.islookup.ISLookUpImpl;
|
||||
import gr.uoa.di.driver.enabling.vocabulary.ISVocabularyLoader;
|
||||
import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader;
|
||||
import eu.dnetlib.repo.manager.clients.ws.validator.ValidatorWebService;
|
||||
import eu.dnetlib.repo.manager.clients.ws.validator.ValidatorWebServiceClient;
|
||||
import gr.uoa.di.driver.util.ServiceLocator;
|
||||
import gr.uoa.di.driver.util.StaticServiceLocator;
|
||||
import gr.uoa.di.driver.xml.VocabularyXmlConverter;
|
||||
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
@ -23,21 +17,14 @@ import org.springframework.context.annotation.Configuration;
|
|||
@ComponentScan(basePackages = {"org.eurocris.openaire.cris.validator.service"})
|
||||
public class Config {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Config.class);
|
||||
|
||||
@Value("${services.provide.iSLookUpService.url}")
|
||||
private String lookupURL;
|
||||
|
||||
@Value("${services.provide.validatorService.url}")
|
||||
private String validatorUrl;
|
||||
|
||||
@Bean(name = "vocabularyLoader")
|
||||
public VocabularyLoader createVocabularyLoader() throws Exception {
|
||||
ISVocabularyLoader loader = new ISVocabularyLoader();
|
||||
|
||||
loader.setLookUp(createVocabularyLookUp());
|
||||
|
||||
return loader;
|
||||
}
|
||||
|
||||
@Bean("validatorServiceLocator")
|
||||
public ServiceLocator<ValidatorService> createValidatorServiceLocator() {
|
||||
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
|
||||
|
@ -55,30 +42,4 @@ public class Config {
|
|||
|
||||
return locator;
|
||||
}
|
||||
|
||||
// @Bean(name="vocabularyLookUp")
|
||||
private ISLookUp<Vocabulary> createVocabularyLookUp() throws Exception {
|
||||
ISLookUpImpl<Vocabulary> lookUp = new ISLookUpImpl<>();
|
||||
|
||||
lookUp.setLookupLocator(createIsLookupServiceLocator());
|
||||
lookUp.setConverter(new VocabularyXmlConverter());
|
||||
|
||||
return lookUp;
|
||||
}
|
||||
|
||||
private ServiceLocator<ISLookUpService> createIsLookupServiceLocator() throws Exception {
|
||||
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
|
||||
|
||||
factory.setServiceClass(eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService.class);
|
||||
factory.setAddress(lookupURL);
|
||||
eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService client = (eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService) factory.create();
|
||||
|
||||
ISLookUpClient service = new ISLookUpClient();
|
||||
service.setWebService(client);
|
||||
|
||||
StaticServiceLocator<ISLookUpService> locator = new StaticServiceLocator<>();
|
||||
locator.setService(service);
|
||||
|
||||
return locator;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,10 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
|
||||
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
||||
|
||||
@Configuration
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true,proxyTargetClass = true)
|
||||
public class GlobalSecurityConfiguration extends GlobalMethodSecurityConfiguration {
|
||||
@EnableMethodSecurity(prePostEnabled = true, proxyTargetClass = true)
|
||||
public class GlobalSecurityConfiguration {
|
||||
|
||||
@Bean
|
||||
public CommonsMultipartResolver multipartResolver(){
|
||||
CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
|
||||
multipartResolver.setMaxUploadSize(268435456);
|
||||
return multipartResolver;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package eu.dnetlib.repo.manager.config;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(RedisConfig.class);
|
||||
|
||||
/**
|
||||
* Custom RedisTemplate using as Value serializer the {@link Jackson2JsonRedisSerializer}
|
||||
* to avoid serialization issues between versions.
|
||||
*
|
||||
* @param connectionFactory the redis connection factory
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
|
||||
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||
template.setConnectionFactory(connectionFactory);
|
||||
template.setValueSerializer(new Jackson2JsonRedisSerializer<>(Object.class));
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
return template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom RedisMessageListenerContainer to override error handling behaviour.
|
||||
*
|
||||
* @param connectionFactory the redis connection factory
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory connectionFactory) {
|
||||
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
||||
container.setConnectionFactory(connectionFactory);
|
||||
container.setErrorHandler(e -> {
|
||||
logger.error("An error occurred in Redis message listener: " + e.getMessage());
|
||||
});
|
||||
return container;
|
||||
}
|
||||
}
|
|
@ -27,7 +27,6 @@ import org.springframework.security.core.Authentication;
|
|||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -286,11 +285,11 @@ public class RepositoryController {
|
|||
/**
|
||||
* Subscribe to repo by email
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.POST, path = "{id}/admins")
|
||||
@RequestMapping(method = RequestMethod.POST, path = "{id}/admins", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
|
||||
public Response subscribeByEmail(@PathVariable("id") String id, @RequestBody String email) throws ResourceNotFoundException {
|
||||
public ResponseEntity<?> subscribeByEmail(@PathVariable("id") String id, @RequestBody String email) throws ResourceNotFoundException {
|
||||
authorizationService.addAdmin(id, email);
|
||||
return Response.status(HttpStatus.OK.value()).entity(JsonUtils.createResponse("Role has been assigned").toString()).type(javax.ws.rs.core.MediaType.APPLICATION_JSON).build();
|
||||
return ResponseEntity.ok(JsonUtils.createResponse("Role has been assigned").toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,108 +1,103 @@
|
|||
//package eu.dnetlib.repo.manager.controllers;
|
||||
//
|
||||
//import eu.dnetlib.repo.manager.domain.dto.Role;
|
||||
//import eu.dnetlib.repo.manager.service.aai.registry.AaiRegistryService;
|
||||
//import eu.dnetlib.repo.manager.service.security.AuthoritiesUpdater;
|
||||
//import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
||||
//import eu.dnetlib.repo.manager.service.security.RoleMappingService;
|
||||
//import eu.dnetlib.repo.manager.utils.JsonUtils;
|
||||
//import io.swagger.annotations.ApiOperation;
|
||||
//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.web.bind.annotation.*;
|
||||
//
|
||||
//import javax.ws.rs.core.MediaType;
|
||||
//import javax.ws.rs.core.Response;
|
||||
//import java.util.Collection;
|
||||
//
|
||||
////@RestController
|
||||
////@RequestMapping(value = "/role-management")
|
||||
////@Api(description = "Role Management", value = "role-management")
|
||||
//public class UserRoleController {
|
||||
//
|
||||
// private final AaiRegistryService aaiRegistryService;
|
||||
// private final AuthoritiesUpdater authoritiesUpdater;
|
||||
// private final RoleMappingService roleMappingService;
|
||||
// private final AuthorizationService authorizationService;
|
||||
//
|
||||
// @Autowired
|
||||
// UserRoleController(AaiRegistryService aaiRegistryService,
|
||||
// AuthoritiesUpdater authoritiesUpdater,
|
||||
// RoleMappingService roleMappingService,
|
||||
// AuthorizationService authorizationService) {
|
||||
// this.aaiRegistryService = aaiRegistryService;
|
||||
// this.authoritiesUpdater = authoritiesUpdater;
|
||||
// this.roleMappingService = roleMappingService;
|
||||
// this.authorizationService = authorizationService;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Get the role with the given id.
|
||||
// **/
|
||||
// @RequestMapping(method = RequestMethod.GET, path = "/role/{id}")
|
||||
//// @PreAuthorize("hasAnyAuthority('REGISTERED_USER', 'SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
|
||||
// public Response getRole(@RequestParam(value = "type", defaultValue = "datasource") String type, @PathVariable("id") String id) {
|
||||
// int roleId = aaiRegistryService.getCouId(type, id);
|
||||
// return Response.status(HttpStatus.OK.value()).entity(JsonUtils.createResponse("Role id is: " + roleId).toString()).type(MediaType.APPLICATION_JSON).build();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Create a new role with the given name and description.
|
||||
// **/
|
||||
// @RequestMapping(method = RequestMethod.POST, path = "/role")
|
||||
// @PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR')")
|
||||
// public Response createRole(@RequestBody Role role) {
|
||||
// aaiRegistryService.createRole(role);
|
||||
// return Response.status(HttpStatus.OK.value()).entity(JsonUtils.createResponse("Role has been created").toString()).type(MediaType.APPLICATION_JSON).build();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Subscribe to a type(Community, etc.) with id(ee, egi, etc.)
|
||||
// */
|
||||
// @ApiOperation(value = "subscribe")
|
||||
// @RequestMapping(method = RequestMethod.POST, path = "/subscribe/{type}/{id}")
|
||||
// @PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
|
||||
// public Response subscribe(@PathVariable("type") String type, @PathVariable("id") String id) {
|
||||
// Integer coPersonId = aaiRegistryService.getCoPersonIdByIdentifier();
|
||||
// if (coPersonId == null) {
|
||||
// coPersonId = aaiRegistryService.getCoPersonIdsByEmail();
|
||||
// }
|
||||
// Integer couId = aaiRegistryService.getCouId(type, id);
|
||||
// if (couId != null) {
|
||||
// aaiRegistryService.assignMemberRole(coPersonId, couId);
|
||||
//
|
||||
// // Add role to current authorities
|
||||
// authoritiesUpdater.addRole(roleMappingService.convertRepoIdToAuthority(id));
|
||||
//
|
||||
// return Response.status(HttpStatus.OK.value()).entity(JsonUtils.createResponse("Role has been assigned").toString()).type(MediaType.APPLICATION_JSON).build();
|
||||
// } else {
|
||||
// return Response.status(HttpStatus.NOT_FOUND.value()).entity(JsonUtils.createResponse("Role has not been found").toString()).type(MediaType.APPLICATION_JSON).build();
|
||||
// }
|
||||
// }
|
||||
// /////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// /////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.GET, path = "/users/couid/{id}")
|
||||
// @PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
|
||||
// public ResponseEntity<String> getUsersByCouId(@PathVariable("id") Integer id) {
|
||||
//// calls.getUserByCoId()
|
||||
// return ResponseEntity.ok(aaiRegistryService.getUsersByCouId(id).toString());
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.GET, path = "/users/{email}/roles")
|
||||
// @PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or hasAuthority('REGISTERED_USER') and authentication.userInfo.email==#email")
|
||||
// public ResponseEntity<Collection<String>> getRolesByEmail(@PathVariable("email") String email) {
|
||||
// return ResponseEntity.ok(authorizationService.getUserRolesByEmail(email));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.GET, path = "/user/roles/my")
|
||||
// @PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
// public ResponseEntity<Collection<String>> getRoleNames() {
|
||||
// return ResponseEntity.ok(authorizationService.getUserRoles());
|
||||
// }
|
||||
//
|
||||
//}
|
||||
package eu.dnetlib.repo.manager.controllers;
|
||||
|
||||
import eu.dnetlib.repo.manager.domain.dto.Role;
|
||||
import eu.dnetlib.repo.manager.service.aai.registry.AaiRegistryService;
|
||||
import eu.dnetlib.repo.manager.service.security.AuthoritiesUpdater;
|
||||
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
||||
import eu.dnetlib.repo.manager.service.security.RoleMappingService;
|
||||
import eu.dnetlib.repo.manager.utils.JsonUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
//@RestController
|
||||
//@RequestMapping(value = "/role-management")
|
||||
//@Api(description = "Role Management", value = "role-management")
|
||||
public class UserRoleController {
|
||||
|
||||
private final AaiRegistryService aaiRegistryService;
|
||||
private final AuthoritiesUpdater authoritiesUpdater;
|
||||
private final RoleMappingService roleMappingService;
|
||||
private final AuthorizationService authorizationService;
|
||||
|
||||
UserRoleController(AaiRegistryService aaiRegistryService,
|
||||
AuthoritiesUpdater authoritiesUpdater,
|
||||
RoleMappingService roleMappingService,
|
||||
AuthorizationService authorizationService) {
|
||||
this.aaiRegistryService = aaiRegistryService;
|
||||
this.authoritiesUpdater = authoritiesUpdater;
|
||||
this.roleMappingService = roleMappingService;
|
||||
this.authorizationService = authorizationService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the role with the given id.
|
||||
**/
|
||||
@RequestMapping(method = RequestMethod.GET, path = "/role/{id}")
|
||||
// @PreAuthorize("hasAnyAuthority('REGISTERED_USER', 'SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
|
||||
public ResponseEntity<?> getRole(@RequestParam(value = "type", defaultValue = "datasource") String type, @PathVariable("id") String id) {
|
||||
int roleId = aaiRegistryService.getCouId(type, id);
|
||||
return ResponseEntity.ok(JsonUtils.createResponse("Role id is: " + roleId).toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new role with the given name and description.
|
||||
**/
|
||||
@RequestMapping(method = RequestMethod.POST, path = "/role")
|
||||
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR')")
|
||||
public ResponseEntity<?> createRole(@RequestBody Role role) {
|
||||
aaiRegistryService.createRole(role);
|
||||
return ResponseEntity.ok(JsonUtils.createResponse("Role has been created").toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to a type(Community, etc.) with id(ee, egi, etc.)
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.POST, path = "/subscribe/{type}/{id}")
|
||||
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
|
||||
public ResponseEntity<?> subscribe(@PathVariable("type") String type, @PathVariable("id") String id) {
|
||||
Integer coPersonId = aaiRegistryService.getCoPersonIdByIdentifier();
|
||||
if (coPersonId == null) {
|
||||
coPersonId = aaiRegistryService.getCoPersonIdsByEmail().get(0);
|
||||
}
|
||||
Integer couId = aaiRegistryService.getCouId(type, id);
|
||||
if (couId != null) {
|
||||
aaiRegistryService.assignMemberRole(coPersonId, couId);
|
||||
|
||||
// Add role to current authorities
|
||||
authoritiesUpdater.addRole(roleMappingService.repositoryIdToAuthority(id));
|
||||
|
||||
return ResponseEntity.ok(JsonUtils.createResponse("Role has been assigned").toString());
|
||||
} else {
|
||||
|
||||
return new ResponseEntity<>(JsonUtils.createResponse("Role has not been found").toString(), HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, path = "/users/couid/{id}")
|
||||
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
|
||||
public ResponseEntity<String> getUsersByCouId(@PathVariable("id") Integer id) {
|
||||
// calls.getUserByCoId()
|
||||
return ResponseEntity.ok(aaiRegistryService.getUsersByCouId(id).toString());
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, path = "/users/{email}/roles")
|
||||
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or hasAuthority('REGISTERED_USER') and authentication.userInfo.email==#email")
|
||||
public ResponseEntity<Collection<String>> getRolesByEmail(@PathVariable("email") String email) {
|
||||
return ResponseEntity.ok(authorizationService.getUserRolesByEmail(email));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, path = "/user/roles/my")
|
||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public ResponseEntity<Collection<String>> getRoleNames() {
|
||||
return ResponseEntity.ok(authorizationService.getUserRoles());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public class ValidatorController {
|
|||
|
||||
@RequestMapping(value = "/getSetsOfRepository" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<String> getSetsOfRepository(@RequestParam(value = "url", required = true) String url) {
|
||||
public List<se.kb.oai.pmh.Set> getSetsOfRepository(@RequestParam(value = "url") String url) {
|
||||
return validatorService.getSetsOfRepository(url);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
public class InterfaceInformation{
|
||||
|
||||
private boolean identified;
|
||||
private List<String> sets;
|
||||
private List<se.kb.oai.pmh.Set> sets;
|
||||
private List<String> adminEmails;
|
||||
|
||||
public InterfaceInformation() {
|
||||
|
@ -23,11 +23,11 @@ public class InterfaceInformation{
|
|||
this.identified = identified;
|
||||
}
|
||||
|
||||
public List<String> getSets() {
|
||||
public List<se.kb.oai.pmh.Set> getSets() {
|
||||
return sets;
|
||||
}
|
||||
|
||||
public void setSets(List<String> sets) {
|
||||
public void setSets(List<se.kb.oai.pmh.Set> sets) {
|
||||
this.sets = sets;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by panagiotis on 15/1/2018.
|
||||
|
@ -11,6 +13,9 @@ public class Term {
|
|||
private String nativeName;
|
||||
private String encoding;
|
||||
private String code;
|
||||
private List<String> synonyms = new ArrayList<>();
|
||||
|
||||
public Term() {}
|
||||
|
||||
public Term(String englishName, String nativeName, String encoding, String code) {
|
||||
this.englishName = englishName;
|
||||
|
@ -19,6 +24,14 @@ public class Term {
|
|||
this.code = code;
|
||||
}
|
||||
|
||||
public Term(String englishName, String nativeName, String encoding, String code, List<String> synonyms) {
|
||||
this.englishName = englishName;
|
||||
this.nativeName = nativeName;
|
||||
this.encoding = encoding;
|
||||
this.code = code;
|
||||
this.synonyms = synonyms;
|
||||
}
|
||||
|
||||
public String getEnglishName() {
|
||||
return englishName;
|
||||
}
|
||||
|
@ -50,4 +63,12 @@ public class Term {
|
|||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public List<String> getSynonyms() {
|
||||
return synonyms;
|
||||
}
|
||||
|
||||
public void setSynonyms(List<String> synonyms) {
|
||||
this.synonyms = synonyms;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,47 @@
|
|||
package eu.dnetlib.repo.manager.domain;
|
||||
|
||||
|
||||
import eu.dnetlib.domain.DriverResource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* Created by stefania on 3/8/16.
|
||||
*
|
||||
* The domain object for the Vocabulary resource data structure
|
||||
*
|
||||
*/
|
||||
public class Vocabulary {
|
||||
@SuppressWarnings("serial")
|
||||
public class Vocabulary extends DriverResource {
|
||||
private String name = null;
|
||||
private Map<String, String> nameMap = null;
|
||||
private Map<String, String> encodingMap = null;
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
public Vocabulary(String name, Map<String, String> nameMap) {
|
||||
this.setResourceType("VocabularyDSResourceType");
|
||||
this.setResourceKind("VocabularyDSResources");
|
||||
|
||||
public Vocabulary() {
|
||||
}
|
||||
|
||||
public Vocabulary(String id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
initializeMaps(nameMap);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
public Vocabulary(String name, Map<String, String> nameMap, Map<String, String> encodingMap) {
|
||||
this.setResourceType("VocabularyDSResourceType");
|
||||
this.setResourceKind("VocabularyDSResources");
|
||||
|
||||
this.name = name;
|
||||
this.nameMap = nameMap;
|
||||
this.encodingMap = encodingMap;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
public void initializeMaps(Map<String, String> nameMap) {
|
||||
this.nameMap = nameMap;
|
||||
this.encodingMap = new TreeMap<String, String>();
|
||||
for (String name : nameMap.keySet()) {
|
||||
encodingMap.put(nameMap.get(name), name);
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
@ -33,4 +51,23 @@ public class Vocabulary {
|
|||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getEncoding(String englishName) {
|
||||
return nameMap.get(englishName);
|
||||
}
|
||||
|
||||
public String getEnglishName(String encoding) {
|
||||
return encodingMap.get(encoding);
|
||||
}
|
||||
|
||||
public List<String> getEnglishNames() {
|
||||
return new ArrayList<String>(this.nameMap.keySet());
|
||||
}
|
||||
|
||||
public List<String> getEncodings() {
|
||||
return new ArrayList<String>(this.encodingMap.keySet());
|
||||
}
|
||||
|
||||
public Map<String, String> getAsMap() { return this.encodingMap; }
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,9 @@ import eu.dnetlib.repo.manager.domain.Term;
|
|||
import eu.dnetlib.repo.manager.domain.Tuple;
|
||||
import eu.dnetlib.repo.manager.domain.broker.*;
|
||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.*;
|
||||
|
@ -34,8 +33,7 @@ import java.util.Map;
|
|||
@Service("brokerService")
|
||||
public class BrokerServiceImpl implements BrokerService {
|
||||
|
||||
@Autowired
|
||||
private RepositoryServiceImpl repoAPI;
|
||||
|
||||
@Value("${services.provide.broker.url}:${services.provide.broker.port}/${services.provide.broker.api}${services.provide.broker.openaire}")
|
||||
private String openairePath;
|
||||
@Value("${services.provide.broker.url}:${services.provide.broker.port}/${services.provide.broker.api}")
|
||||
|
@ -45,13 +43,19 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(BrokerServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
RestTemplate restTemplate;
|
||||
private final RepositoryService repoAPI;
|
||||
private final RestTemplate restTemplate;
|
||||
|
||||
private HttpHeaders httpHeaders;
|
||||
|
||||
private final HashMap<String, Term> topics = new HashMap<>();
|
||||
|
||||
public BrokerServiceImpl(RepositoryService repositoryService, RestTemplate restTemplate) {
|
||||
logger.info("init broker service");
|
||||
this.repoAPI = repositoryService;
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
private void initDnetTopicsMap() {
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.springframework.stereotype.Service;
|
|||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service("monitorService")
|
||||
public class MonitorServiceImpl implements MonitorService {
|
||||
|
@ -124,6 +124,7 @@ public class MonitorServiceImpl implements MonitorService {
|
|||
if (retJobs.getJobs() != null) {
|
||||
jobs.addAll(retJobs.getJobs());
|
||||
}
|
||||
jobs.sort((s1, s2) -> s2.getStarted().compareTo(s1.getStarted()));
|
||||
// set all jobs back to retJobs
|
||||
retJobs.setJobs(jobs);
|
||||
}
|
||||
|
@ -170,16 +171,20 @@ public class MonitorServiceImpl implements MonitorService {
|
|||
try {
|
||||
job = getValidationService().getStoredJob(Integer.parseInt(jobId), groupBy);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
if (e.getMessage() == null) {
|
||||
logger.warn("Job with id '{}' not found in Validator. Trying CRIS...", jobId);
|
||||
} else {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
if (job == null) {
|
||||
// not a good way to do it but Job id field is string
|
||||
List<Job> cJobs = crisJobs.getAll().stream().filter(j -> j.getId().hashCode() == Integer.parseInt(jobId)).collect(Collectors.toList());
|
||||
if (!cJobs.isEmpty()) {
|
||||
job = CrisValidatorUtils.convertJobToStoredJob(cJobs.get(0));
|
||||
Optional<Job> cJob = crisJobs.get(jobId);
|
||||
if (cJob.isPresent()) {
|
||||
job = CrisValidatorUtils.convertJobToStoredJob(cJob.get());
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -6,12 +6,14 @@ import eu.dnetlib.repo.manager.domain.OrderByField;
|
|||
import eu.dnetlib.repo.manager.domain.OrderByType;
|
||||
import eu.dnetlib.repo.manager.domain.Repository;
|
||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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.DataAccessException;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -177,12 +179,8 @@ public class PiWikServiceImpl implements PiWikService {
|
|||
emailUtils.sendAdministratorMetricsEnabled(piwikInfo);
|
||||
emailUtils.sendUserMetricsEnabled(piwikInfo);
|
||||
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
logger.error("Error while approving piwik site: ", 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);
|
||||
throw new RepositoryServiceException(e, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
} catch (DataAccessException e) {
|
||||
throw new RepositoryServiceException("Error while approving piwik site: " + e.getMessage(), e, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
}
|
||||
return new ResponseEntity<>("OK", HttpStatus.OK);
|
||||
}
|
||||
|
@ -212,14 +210,11 @@ public class PiWikServiceImpl implements PiWikService {
|
|||
emailUtils.sendAdministratorRequestToEnableMetrics(piwikInfo);
|
||||
emailUtils.sendUserRequestToEnableMetrics(piwikInfo);
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
logger.error("Error while creating piwikScript URL", uee);
|
||||
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
throw new RepositoryServiceException("Error while creating piwikScript URL", uee, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
} catch (IOException ioe) {
|
||||
logger.error("Error while creating piwik site", 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);
|
||||
throw new RepositoryServiceException(e, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
throw new RepositoryServiceException("Error while creating piwik site", ioe, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
} catch (ResourceNotFoundException e) {
|
||||
throw new RepositoryServiceException("Repository with id '" + piwikInfo.getRepositoryId() + "' was not found.", e, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
}
|
||||
return piwikInfo;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||
import eu.dnetlib.domain.enabling.Vocabulary;
|
||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||
import eu.dnetlib.repo.manager.domain.*;
|
||||
import eu.dnetlib.repo.manager.domain.dto.User;
|
||||
|
@ -16,7 +15,6 @@ import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
|||
import eu.dnetlib.repo.manager.service.security.RoleMappingService;
|
||||
import eu.dnetlib.repo.manager.utils.Converter;
|
||||
import eu.dnetlib.repo.manager.utils.DateUtils;
|
||||
import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -106,38 +104,42 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
private void init() {
|
||||
logger.debug("Initialization method of repository api! Updated version!");
|
||||
|
||||
for (String key : this.getVocabulary("dnet:datasource_typologies").getAsMap().keySet()) {
|
||||
if (key.contains("aggregator")) {
|
||||
dataSourceClass.putIfAbsent("aggregator", new ArrayList<>());
|
||||
dataSourceClass.get("aggregator").add(key);
|
||||
} else if (key.contains("crissystem")) {
|
||||
dataSourceClass.putIfAbsent("dris", new ArrayList<>());
|
||||
dataSourceClass.get("dris").add(key);
|
||||
} else if (key.contains("pubsrepository::journal")) { // do not change order -->
|
||||
dataSourceClass.putIfAbsent("journal", Collections.singletonList("pubsrepository::journal"));
|
||||
} else if (key.contains("pubsrepository")) { // do not change order <--
|
||||
dataSourceClass.putIfAbsent("opendoar", new ArrayList<>());
|
||||
dataSourceClass.get("opendoar").add(key);
|
||||
} else if (key.contains("datarepository")) {
|
||||
dataSourceClass.putIfAbsent("re3data", Collections.singletonList("datarepository::unknown"));
|
||||
try {
|
||||
for (String key : this.getVocabulary("dnet:datasource_typologies").getAsMap().keySet()) {
|
||||
if (key.contains("aggregator")) {
|
||||
dataSourceClass.putIfAbsent("aggregator", new ArrayList<>());
|
||||
dataSourceClass.get("aggregator").add(key);
|
||||
} else if (key.contains("crissystem")) {
|
||||
dataSourceClass.putIfAbsent("dris", new ArrayList<>());
|
||||
dataSourceClass.get("dris").add(key);
|
||||
} else if (key.contains("pubsrepository::journal")) { // do not change order -->
|
||||
dataSourceClass.putIfAbsent("journal", Collections.singletonList("pubsrepository::journal"));
|
||||
} else if (key.contains("pubsrepository")) { // do not change order <--
|
||||
dataSourceClass.putIfAbsent("opendoar", new ArrayList<>());
|
||||
dataSourceClass.get("opendoar").add(key);
|
||||
} else if (key.contains("datarepository")) {
|
||||
dataSourceClass.putIfAbsent("re3data", Collections.singletonList("datarepository::unknown"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<String, List<String>> entry : dataSourceClass.entrySet()) {
|
||||
entry.getValue().forEach(v -> invertedDataSourceClass.put(v, entry.getKey()));
|
||||
}
|
||||
for (Map.Entry<String, List<String>> entry : dataSourceClass.entrySet()) {
|
||||
entry.getValue().forEach(v -> invertedDataSourceClass.put(v, entry.getKey()));
|
||||
}
|
||||
|
||||
httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
for (String vocName : vocabularyNames) {
|
||||
vocabularyMap.put(vocName, vocabularyLoader.getVocabulary(vocName, Locale.ENGLISH, Locale.ROOT));
|
||||
}
|
||||
for (String vocName : vocabularyNames) {
|
||||
this.getVocabulary(vocName);
|
||||
}
|
||||
|
||||
Country[] countries = getCountries();
|
||||
for (Country c : countries) {
|
||||
countriesMap.put(c.getName(), c.getCode());
|
||||
inverseCountriesMap.put(c.getCode(), c.getName());
|
||||
Country[] countries = getCountries();
|
||||
for (Country c : countries) {
|
||||
countriesMap.put(c.getName(), c.getCode());
|
||||
inverseCountriesMap.put(c.getCode(), c.getName());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Could not retrieve vocabularies", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -772,16 +774,11 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
}
|
||||
|
||||
@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);
|
||||
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
}
|
||||
public MetricsInfo getMetricsInfoForRepository(String repoId) {
|
||||
MetricsInfo metricsInfo = new MetricsInfo();
|
||||
metricsInfo.setDiagramsBaseURL(this.usageStatisticsDiagramsBaseURL);
|
||||
metricsInfo.setMetricsNumbers(getMetricsNumbers(getOpenAIREId(repoId)));
|
||||
return metricsInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -851,13 +848,8 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
//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;
|
||||
|
||||
//communicate with endpoint
|
||||
resp = template.exchange(
|
||||
ResponseEntity<MetricsNumbers> resp = restTemplate.exchange(
|
||||
builder.build().encode().toUri(),
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
|
|
|
@ -23,7 +23,7 @@ public interface ValidatorService {
|
|||
|
||||
List<RuleSet> getRuleSets(String mode);
|
||||
|
||||
List<String> getSetsOfRepository(String url);
|
||||
List<se.kb.oai.pmh.Set> getSetsOfRepository(String url);
|
||||
|
||||
boolean identifyRepo(String url);
|
||||
|
||||
|
|
|
@ -208,9 +208,9 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSetsOfRepository(String url) {
|
||||
public List<se.kb.oai.pmh.Set> getSetsOfRepository(String url) {
|
||||
logger.debug("Getting sets of repository with url : {}", url);
|
||||
List<String> sets = null;
|
||||
List<se.kb.oai.pmh.Set> sets = null;
|
||||
try {
|
||||
sets = OaiTools.getSetsOfRepo(url);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package eu.dnetlib.repo.manager.service;
|
||||
|
||||
import eu.dnetlib.repo.manager.domain.Vocabulary;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public interface VocabularyLoader {
|
||||
|
||||
public abstract Vocabulary getVocabulary(String vocabularyName, Locale locale, Locale defaultLocale);
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@ import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
|||
import org.mitre.openid.connect.model.UserInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
|
@ -34,10 +34,9 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
|||
private final AuthoritiesUpdater authoritiesUpdater;
|
||||
private final PendingUserRoleRepository pendingUserRoleRepository;
|
||||
|
||||
@Autowired
|
||||
AuthorizationServiceImpl(RoleMappingService roleMappingService, AaiRegistryService aaiRegistryService,
|
||||
AuthoritiesUpdater authoritiesUpdater,
|
||||
PendingUserRoleRepository pendingUserRoleRepository) {
|
||||
@Lazy PendingUserRoleRepository pendingUserRoleRepository) {
|
||||
this.roleMappingService = roleMappingService;
|
||||
this.aaiRegistryService = aaiRegistryService;
|
||||
this.authoritiesUpdater = authoritiesUpdater;
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package eu.dnetlib.repo.manager.service.vocabulary;
|
||||
|
||||
import eu.dnetlib.repo.manager.domain.Term;
|
||||
import eu.dnetlib.repo.manager.domain.Vocabulary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class DnetVocabulary {
|
||||
private String id;
|
||||
private String name;
|
||||
private String description;
|
||||
private String code;
|
||||
private List<Term> terms = new ArrayList<>();
|
||||
|
||||
public DnetVocabulary() {
|
||||
}
|
||||
|
||||
public static Vocabulary toVocabulary(DnetVocabulary vocabulary) {
|
||||
Map<String, String> nameMap = new TreeMap<>();
|
||||
Map<String, String> encodingMap = new TreeMap<>();
|
||||
for (Term term : vocabulary.getTerms()) {
|
||||
nameMap.put(term.getEnglishName(), term.getCode());
|
||||
encodingMap.put(term.getCode(), term.getEnglishName());
|
||||
}
|
||||
return new Vocabulary(vocabulary.getName(), nameMap, encodingMap);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public List<Term> getTerms() {
|
||||
return terms;
|
||||
}
|
||||
|
||||
public void setTerms(List<Term> terms) {
|
||||
this.terms = terms;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package eu.dnetlib.repo.manager.service.vocabulary;
|
||||
|
||||
import eu.dnetlib.repo.manager.domain.Vocabulary;
|
||||
import eu.dnetlib.repo.manager.service.VocabularyLoader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@Service
|
||||
@Primary
|
||||
public class JsonApiVocabularyLoader implements VocabularyLoader {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(JsonApiVocabularyLoader.class);
|
||||
private static final String url = "%s/provision/mvc/vocabularies/%s.json";
|
||||
|
||||
private final String endpoint;
|
||||
private final RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
public JsonApiVocabularyLoader(@Value("${services.openaireServicesBaseUrl}") String endpoint) {
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vocabulary getVocabulary(String vocabularyName, Locale locale, Locale defaultLocale) {
|
||||
DnetVocabulary voc = restTemplate.getForObject(String.format(url, endpoint, vocabularyName), DnetVocabulary.class);
|
||||
if (voc == null) {
|
||||
logger.error("Error retrieving vocabulary '{}'", vocabularyName);
|
||||
return null;
|
||||
}
|
||||
return DnetVocabulary.toVocabulary(voc);
|
||||
}
|
||||
}
|
|
@ -8,9 +8,8 @@ import org.eurocris.openaire.cris.validator.model.RuleResults;
|
|||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CrisValidatorUtils {
|
||||
|
||||
|
@ -18,18 +17,19 @@ public class CrisValidatorUtils {
|
|||
private static final DateFormat DURATION_FORMATTER = new SimpleDateFormat("HH 'hours' mm 'min' ss 'sec'");
|
||||
|
||||
public static StoredJob convertJobToStoredJob(Job job) {
|
||||
DURATION_FORMATTER.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
StoredJob sj = new StoredJob();
|
||||
sj.setId(job.getId().hashCode());
|
||||
sj.setId(job.getId());
|
||||
sj.setValidationStatus(job.getStatus());
|
||||
|
||||
Date dateFinished = job.getDateFinished();
|
||||
Date dateStarted = job.getDateStarted();
|
||||
if ( dateFinished != null ) {
|
||||
if (dateFinished != null) {
|
||||
sj.setEnded(DATE_FORMATTER.format(dateFinished));
|
||||
sj.setDuration(DURATION_FORMATTER.format(new Date(dateFinished.getTime() - dateStarted.getTime())));
|
||||
} else {
|
||||
sj.setEnded("-");
|
||||
sj.setDuration("-");
|
||||
sj.setDuration(DURATION_FORMATTER.format(new Date(new Date().getTime() - dateStarted.getTime())));
|
||||
}
|
||||
sj.setStarted(DATE_FORMATTER.format(dateStarted));
|
||||
|
||||
|
@ -47,10 +47,11 @@ public class CrisValidatorUtils {
|
|||
sj.setContentJobStatus(job.getContentJobStatus());
|
||||
|
||||
// Set scores
|
||||
// sj.setFilteredScores(); // TODO what is this?
|
||||
sj.setFilteredScores(Map.of("all", job.getContentScore())); // TODO what is this?
|
||||
sj.setContentJobScore(job.getContentScore());
|
||||
sj.setUsageJobScore(job.getUsageScore());
|
||||
|
||||
sj.setRules(job.getRuleResults().stream().map(r -> r.getRule().getId()).collect(Collectors.toSet()));
|
||||
sj.setResultEntries(CrisValidatorUtils.crisResultsToJobEntries(job));
|
||||
sj.setRecordsTested(job.getRecordsTested());
|
||||
|
||||
|
@ -59,6 +60,9 @@ public class CrisValidatorUtils {
|
|||
|
||||
public static List<JobResultEntry> crisResultsToJobEntries(Job crisJob) {
|
||||
List<JobResultEntry> jobResultEntries = new ArrayList<>();
|
||||
if (crisJob.getRuleResults() == null) {
|
||||
crisJob.setRuleResults(new ArrayList<>());
|
||||
}
|
||||
for (RuleResults ruleResults : crisJob.getRuleResults()) {
|
||||
Rule rule = ruleResults.getRule();
|
||||
JobResultEntry jobResultEntry = new JobResultEntry();
|
||||
|
|
|
@ -15,7 +15,7 @@ import java.security.KeyManagementException;
|
|||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class OaiTools {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OaiTools.class);
|
||||
|
||||
public static List<String> getSetsOfRepo(String baseUrl) throws Exception {
|
||||
public static List<se.kb.oai.pmh.Set> getSetsOfRepo(String baseUrl) throws Exception {
|
||||
try {
|
||||
logger.debug("Getting sets of repository: {}", baseUrl);
|
||||
OaiPmhServer harvester = new OaiPmhServer(baseUrl);
|
||||
|
@ -40,18 +40,12 @@ public class OaiTools {
|
|||
token = setList.getResumptionToken();
|
||||
}
|
||||
|
||||
List<String> ret = new ArrayList<String>();
|
||||
for (Set set : sets) {
|
||||
ret.add(set.getSpec().trim());
|
||||
}
|
||||
if (ret.size() > 0 )
|
||||
Collections.sort(ret);
|
||||
return ret;
|
||||
sets.sort(Comparator.comparing(Set::getName));
|
||||
return sets;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error getting sets of repository " + baseUrl, e);
|
||||
return new ArrayList<String>();
|
||||
//throw e;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,16 +8,13 @@ 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 {
|
||||
HttpStatus.Series seriesError = httpResponse.getStatusCode().series();
|
||||
return ( (seriesError == CLIENT_ERROR) || (seriesError == SERVER_ERROR) );
|
||||
HttpStatus statusCode = httpResponse.getStatusCode();
|
||||
return ( (statusCode.is4xxClientError()) || (statusCode.is5xxServerError()) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,7 +23,7 @@ public class RestTemplateResponseErrorHandler implements ResponseErrorHandler {
|
|||
HttpStatus statusCode = httpResponse.getStatusCode();
|
||||
if ( statusCode == HttpStatus.NOT_FOUND )
|
||||
throw new IOException();
|
||||
else if (statusCode.series() == SERVER_ERROR)
|
||||
else if (statusCode.is5xxServerError())
|
||||
throw new EndPointException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
rule.weights={\
|
||||
check000_Identify: '33.33333', \
|
||||
check010_MetadataFormats: '33.33333', \
|
||||
check020_Sets: '33.33333', \
|
||||
check100_CheckPublications: '10', \
|
||||
check200_CheckProducts: '10', \
|
||||
check300_CheckPatents: '10',\
|
||||
check400_CheckPersons: '10', \
|
||||
check500_CheckOrgUnits: '10', \
|
||||
check600_CheckProjects: '10', \
|
||||
check700_CheckFundings: '10', \
|
||||
check800_CheckEquipment: '10', \
|
||||
check900_CheckEvents: '10', \
|
||||
check990_CheckReferentialIntegrityAndFunctionalDependency: '10'}
|
||||
|
||||
# don't leave empty spaces
|
||||
rule.names={\
|
||||
check000_Identify:'Identify',\
|
||||
check010_MetadataFormats:'Metadata Formats',\
|
||||
check020_Sets:'Sets',\
|
||||
check100_CheckPublications:'Publications',\
|
||||
check200_CheckProducts:'Products',\
|
||||
check300_CheckPatents:'Patents',\
|
||||
check400_CheckPersons:'Persons',\
|
||||
check500_CheckOrgUnits:'OrgUnits',\
|
||||
check600_CheckProjects:'Projects',\
|
||||
check700_CheckFundings:'Fundings',\
|
||||
check800_CheckEquipment:'Equipment',\
|
||||
check900_CheckEvents:'Events',\
|
||||
check990_CheckReferentialIntegrityAndFunctionalDependency:'Referential Integrity And Functional Dependency'\
|
||||
}
|
||||
|
||||
# don't leave empty spaces
|
||||
rule.types={\
|
||||
check000_Identify:'USAGE',\
|
||||
check010_MetadataFormats:'USAGE',\
|
||||
check020_Sets:'USAGE',\
|
||||
check100_CheckPublications:'CONTENT',\
|
||||
check200_CheckProducts:'CONTENT',\
|
||||
check300_CheckPatents:'CONTENT',\
|
||||
check400_CheckPersons:'CONTENT',\
|
||||
check500_CheckOrgUnits:'CONTENT',\
|
||||
check600_CheckProjects:'CONTENT',\
|
||||
check700_CheckFundings:'CONTENT',\
|
||||
check800_CheckEquipment:'CONTENT',\
|
||||
check900_CheckEvents:'CONTENT',\
|
||||
check990_CheckReferentialIntegrityAndFunctionalDependency:'CONTENT'\
|
||||
}
|
||||
|
||||
# don't leave empty spaces
|
||||
rule.descriptions={\
|
||||
check000_Identify:'-',\
|
||||
check010_MetadataFormats:'-',\
|
||||
check020_Sets:'-',\
|
||||
check100_CheckPublications:'A text based scholarly publication or publishing channel that contains results of research. CRISs typically record metadata about scholarly publications from the scope of the CRIS (institutional CRIS for the institution, funder CRIS for the funding it distributed, etc.) in the context of the research projects, infrastructure, funding, organization units and authors/contributors. This entity typically represents the granularity level of a single published item for which attribution information is attached (usually in the form of a list of authors and contributors).<p><a href="https://openaire-guidelines-for-cris-managers.readthedocs.io/en/v1.1.1/cerif_xml_publication_entity.html">View guideline</a></p>',\
|
||||
check200_CheckProducts:'Any result of research other than Publication or Patent. This includes: (1) research datasets, (2) software, (3) visualisations: still or moving images, including maps and other cartographic material, (4) audio recordings, (5) other objects that can be perceived through human senses. <p><a href="https://openaire-guidelines-for-cris-managers.readthedocs.io/en/v1.1.1/cerif_xml_product_entity.html">View guideline</a></p>',\
|
||||
check300_CheckPatents:'A set of exclusive rights granted by a sovereign state to an inventor or assignee for a limited period of time in exchange for detailed public disclosure of an invention. <p><a href="https://openaire-guidelines-for-cris-managers.readthedocs.io/en/v1.1.1/cerif_xml_patent_entity.html">View guideline</a></p>',\
|
||||
check400_CheckPersons:'A human being as an individual. Source: https://en.oxforddictionaries.com/definition/person The kind of involvement of a Person in the research ecosystem is specified in the links with the organisations, the services, etc. <p><a href="https://openaire-guidelines-for-cris-managers.readthedocs.io/en/v1.1.1/cerif_xml_person_entity.html">View guideline</a></p>',\
|
||||
check500_CheckOrgUnits:'Organisation Unit: an organisation, a unit therein, a committee or any other group of people that has a collective goal. Organisation Units are not necessarily formalized as legal entities. <p><a href="https://openaire-guidelines-for-cris-managers.readthedocs.io/en/v1.1.1/cerif_xml_organisation_entity.html">View guideline</a></p>',\
|
||||
check600_CheckProjects:'A temporary endeavor undertaken to create a unique product, service or result. Source: the Project Management Institute, https://www.pmi.org/about/learn-about-pmi/what-is-project-management . <p><a href="https://openaire-guidelines-for-cris-managers.readthedocs.io/en/v1.1.1/cerif_xml_project_entity.html">View guideline</a></p>',\
|
||||
check700_CheckFundings:'CRIS compatible with the OpenAIRE Guidelines for CRIS Managers. <p><a href="https://openaire-guidelines-for-cris-managers.readthedocs.io/en/v1.1.1/cerif_xml_funding_entity.html">View guideline</a></p>',\
|
||||
check800_CheckEquipment:'An equipment is an instrumentality needed for an undertaking or to perform a service: Definition Source: http://wordnetweb.princeton.edu/perl/webwn?s=equipment . <p><a href="https://openaire-guidelines-for-cris-managers.readthedocs.io/en/v1.1.1/cerif_xml_equipment_entity.html">View guideline</a></p>',\
|
||||
check900_CheckEvents:'An event is something that happens at a given place and time. Definition Source: http://wordnetweb.princeton.edu/perl/webwn?s=event . <p><a href="https://openaire-guidelines-for-cris-managers.readthedocs.io/en/v1.1.1/cerif_xml_event_entity.html">View guideline</a></p>',\
|
||||
check990_CheckReferentialIntegrityAndFunctionalDependency:'-'\
|
||||
}
|
Loading…
Reference in New Issue