Compare commits
3 Commits
fe7a8b1631
...
376715c1af
Author | SHA1 | Date |
---|---|---|
Katerina | 376715c1af | |
Katerina | e6c5fa5919 | |
Katerina | 61756adf8c |
51
pom.xml
51
pom.xml
|
@ -3,7 +3,6 @@
|
|||
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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>validator-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
@ -12,47 +11,80 @@
|
|||
<scm>
|
||||
<developerConnection>scm:git:gitea@code-repo.d4science.org:MaDgIK/uoa-validator-api.git</developerConnection>
|
||||
</scm>
|
||||
|
||||
<parent>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>uoa-spring-boot-parent</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.7.10</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<timestamp>${maven.build.timestamp}</timestamp>
|
||||
<maven.build.timestamp.format>E MMM dd HH:mm:ss z yyyy</maven.build.timestamp.format>
|
||||
<java.vesrion>11</java.vesrion>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<spring-boot-version>2.7.10</spring-boot-version>
|
||||
<apache.camel.version>3.20.5</apache.camel.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- validator -->
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>uoa-validator-engine2</artifactId>
|
||||
<version>0.9.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- spring boot -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>${spring-boot-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<version>${spring-boot-version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- jpa, crud repository -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
<version>${spring-boot-version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- PostgreSQL -->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>9.4.1212.jre7</version>
|
||||
</dependency>
|
||||
|
||||
<!--Apache Camel -->
|
||||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-core</artifactId>
|
||||
<version>3.20.3</version>
|
||||
<version>${apache.camel.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-oaipmh</artifactId>
|
||||
<version>3.20.3</version>
|
||||
<version>${apache.camel.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel.springboot</groupId>
|
||||
<artifactId>camel-spring-boot</artifactId>
|
||||
<version>${apache.camel.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel.springboot</groupId>
|
||||
<artifactId>camel-spring-boot-starter</artifactId>
|
||||
<version>${apache.camel.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -60,7 +92,7 @@
|
|||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>1.5.8.RELEASE</version>
|
||||
<version>1.5.22.RELEASE</version>
|
||||
<configuration>
|
||||
<mainClass>eu.dnetlib.validatorapi.ValidatorApiApplication</mainClass>
|
||||
<executable>true</executable>
|
||||
|
@ -69,6 +101,7 @@
|
|||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
<goal>build-info</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
package eu.dnetlib.validatorapi;
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.support.SpringBootServletInitializer;
|
||||
|
||||
public class ServletInitializer extends SpringBootServletInitializer {
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(ValidatorApiApplication.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +1,7 @@
|
|||
package eu.dnetlib.validatorapi;
|
||||
|
||||
import eu.dnetlib.validatorapi.configuration.GlobalVars;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.context.annotation.PropertySources;
|
||||
|
||||
|
@ -12,7 +10,7 @@ import org.springframework.context.annotation.PropertySources;
|
|||
@PropertySource("classpath:validatorapi.properties"),
|
||||
@PropertySource(value = "classpath:dnet-override.properties", ignoreResourceNotFound = true)
|
||||
})
|
||||
@EnableConfigurationProperties({GlobalVars.class})
|
||||
|
||||
public class ValidatorApiApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ValidatorApiApplication.class, args);
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
package eu.dnetlib.validatorapi.configuration;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ConfigurationProperties("validatorapi.globalVars")
|
||||
public class GlobalVars {
|
||||
public static Date date = new Date();
|
||||
private Date buildDate;
|
||||
private String version;
|
||||
|
||||
public String getBuildDate() {
|
||||
if(buildDate == null) {
|
||||
return null;
|
||||
}
|
||||
return buildDate.toString();
|
||||
}
|
||||
|
||||
public void setBuildDate(Date buildDate) {
|
||||
this.buildDate = buildDate;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
package eu.dnetlib.validatorapi;
|
||||
package eu.dnetlib.validatorapi.configuration;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class ValidatorApiConfiguration extends WebMvcConfigurerAdapter {
|
||||
public class ValidatorApiConfiguration implements WebMvcConfigurer {
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
@Bean
|
|
@ -13,7 +13,6 @@ import eu.dnetlib.validatorapi.repositories.ValidationResultRepository;
|
|||
import eu.dnetlib.validatorapi.routes.OaiPmhRoute;
|
||||
import org.apache.camel.CamelContext;
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
import org.apache.camel.impl.DefaultCamelContext;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -54,6 +53,9 @@ public class ValidationController {
|
|||
private final ValidationResultRepository validationResultRepository;
|
||||
private final ValidationIssueRepository validationIssueRepository;
|
||||
|
||||
@Autowired
|
||||
CamelContext camelContext;
|
||||
|
||||
@Autowired
|
||||
public ValidationController(ValidationJobRepository validationJobRepository,
|
||||
ValidationResultRepository validationResultRepository,
|
||||
|
@ -200,12 +202,12 @@ public class ValidationController {
|
|||
try {
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||
CamelContext camelContext = new DefaultCamelContext();
|
||||
|
||||
RouteBuilder oaiPmhRouteBuilder =
|
||||
new OaiPmhRoute("oaipmh://"+baseURL + "?verb=ListRecords&metadataPrefix=" + metadataPrefix ,
|
||||
profile, validationJob, numberOfRecords, validationIssueRepository, validationResultRepository);
|
||||
camelContext.addRoutes(oaiPmhRouteBuilder);
|
||||
camelContext.start();
|
||||
//camelContext.start();
|
||||
//camelContext.stop();
|
||||
validationJob.status = "COMPLETED";
|
||||
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
package eu.dnetlib.validatorapi.controllers;
|
||||
|
||||
import eu.dnetlib.validatorapi.configuration.GlobalVars;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class ValidatorApiCheckDeployController {
|
||||
private static final Logger log = LogManager.getLogger(ValidatorApiCheckDeployController.class);
|
||||
|
||||
@Autowired
|
||||
private GlobalVars globalVars;
|
||||
|
||||
@RequestMapping(value = {"", "/health_check"}, method = RequestMethod.GET)
|
||||
public String hello() {
|
||||
log.debug("Hello from validator-api!");
|
||||
return "Hello from validator-api!";
|
||||
}
|
||||
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/health_check/advanced", method = RequestMethod.GET)
|
||||
public Map<String, String> checkEverything() {
|
||||
Map<String, String> response = new HashMap<>();
|
||||
|
||||
if(globalVars.date != null) {
|
||||
response.put("Date of deploy", globalVars.date.toString());
|
||||
}
|
||||
if(globalVars.getBuildDate() != null) {
|
||||
response.put("Date of build", globalVars.getBuildDate());
|
||||
}
|
||||
if(globalVars.getVersion() != null) {
|
||||
response.put("Version", globalVars.getVersion());
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ import org.apache.camel.builder.RouteBuilder;
|
|||
|
||||
public class OaiPmhRoute extends RouteBuilder {
|
||||
|
||||
private String oaiEndpoint = "oaipmh://http://repositorium.sdum.uminho.pt/oai/request";
|
||||
private String oaiEndpoint;
|
||||
|
||||
private AbstractOpenAireProfile profile;
|
||||
private long maxNumberOfRecords = 0;
|
||||
|
@ -38,6 +38,7 @@ public class OaiPmhRoute extends RouteBuilder {
|
|||
.setProperty("totalRecords", constant(0))
|
||||
.loopDoWhile().simple("${exchangeProperty.totalRecords} < 10")
|
||||
.split(xpath("//*[local-name()='record']"))
|
||||
.log("${exchangeProperty.totalRecords}")
|
||||
// .log("\n\n\n----------------\n\n\n\n\n\n${body}\n\n\n----------------\n\n\n\n\n\n")
|
||||
.process(new XmlProcessor(profile, validationJob, validationIssueRepository, validationResultRepository))
|
||||
.end().to("direct:end");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.dnetlib.validatorapi.utils;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -34,20 +34,21 @@ public class CustomStringArrayType implements UserType {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
||||
public Object nullSafeGet(ResultSet resultSet, String[] names,
|
||||
SharedSessionContractImplementor sharedSessionContractImplementor, Object o)
|
||||
throws HibernateException, SQLException {
|
||||
Array array = rs.getArray(names[0]);
|
||||
Array array = resultSet.getArray(names[0]);
|
||||
return array != null ? array.getArray() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
|
||||
throws HibernateException, SQLException {
|
||||
if (value != null && st != null) {
|
||||
Array array = session.connection().createArrayOf("text", (String[])value);
|
||||
st.setArray(index, array);
|
||||
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index,
|
||||
SharedSessionContractImplementor sharedSessionContractImplementor) throws HibernateException, SQLException {
|
||||
if (value != null && preparedStatement != null) {
|
||||
Array array = sharedSessionContractImplementor.connection().createArrayOf("text", (String[])value);
|
||||
preparedStatement.setArray(index, array);
|
||||
} else {
|
||||
st.setNull(index, sqlTypes()[0]);
|
||||
preparedStatement.setNull(index, sqlTypes()[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
validatorapi.globalVars.buildDate=@timestamp@
|
||||
validatorapi.globalVars.version=@version@
|
||||
#validatorapi.globalVars.buildDate=@timestamp@
|
||||
#validatorapi.globalVars.version=@version@
|
Loading…
Reference in New Issue