added spring-boot-2 and apache camle dependencies. Autowired CamelContext
This commit is contained in:
parent
61756adf8c
commit
e6c5fa5919
19
pom.xml
19
pom.xml
|
@ -15,7 +15,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>1.5.22.RELEASE</version>
|
<version>2.7.10</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
<maven.compiler.source>11</maven.compiler.source>
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
<maven.compiler.target>11</maven.compiler.target>
|
||||||
<spring-boot-version>1.5.22.RELEASE</spring-boot-version>
|
<spring-boot-version>1.5.22.RELEASE</spring-boot-version>
|
||||||
|
<apache.camel.version>3.20.5</apache.camel.version>
|
||||||
<!--gson-version>2.9.0</gson-version-->
|
<!--gson-version>2.9.0</gson-version-->
|
||||||
<!--swagger-version>2.7.0</swagger-version-->
|
<!--swagger-version>2.7.0</swagger-version-->
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -64,13 +65,25 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.camel</groupId>
|
<groupId>org.apache.camel</groupId>
|
||||||
<artifactId>camel-core</artifactId>
|
<artifactId>camel-core</artifactId>
|
||||||
<version>3.20.5</version>
|
<version>${apache.camel.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.camel</groupId>
|
<groupId>org.apache.camel</groupId>
|
||||||
<artifactId>camel-oaipmh</artifactId>
|
<artifactId>camel-oaipmh</artifactId>
|
||||||
<version>3.20.5</version>
|
<version>${apache.camel.version}</version>
|
||||||
</dependency>
|
</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>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -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,33 +0,0 @@
|
||||||
package eu.dnetlib.validatorapi.configuration;
|
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@ConfigurationProperties("validatorapi.globalVars")
|
|
||||||
@Validated
|
|
||||||
public class GlobalVars {
|
|
||||||
public static Date date = new Date();
|
|
||||||
private String buildDate;
|
|
||||||
private String version;
|
|
||||||
|
|
||||||
public String getBuildDate() {
|
|
||||||
if(buildDate == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return buildDate.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBuildDate(String 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.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class ValidatorApiConfiguration extends WebMvcConfigurerAdapter {
|
public class ValidatorApiConfiguration implements WebMvcConfigurer {
|
||||||
private final Logger log = LogManager.getLogger(this.getClass());
|
private final Logger log = LogManager.getLogger(this.getClass());
|
||||||
|
|
||||||
@Bean
|
@Bean
|
|
@ -13,7 +13,6 @@ import eu.dnetlib.validatorapi.repositories.ValidationResultRepository;
|
||||||
import eu.dnetlib.validatorapi.routes.OaiPmhRoute;
|
import eu.dnetlib.validatorapi.routes.OaiPmhRoute;
|
||||||
import org.apache.camel.CamelContext;
|
import org.apache.camel.CamelContext;
|
||||||
import org.apache.camel.builder.RouteBuilder;
|
import org.apache.camel.builder.RouteBuilder;
|
||||||
import org.apache.camel.impl.DefaultCamelContext;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -54,6 +53,9 @@ public class ValidationController {
|
||||||
private final ValidationResultRepository validationResultRepository;
|
private final ValidationResultRepository validationResultRepository;
|
||||||
private final ValidationIssueRepository validationIssueRepository;
|
private final ValidationIssueRepository validationIssueRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CamelContext camelContext;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ValidationController(ValidationJobRepository validationJobRepository,
|
public ValidationController(ValidationJobRepository validationJobRepository,
|
||||||
ValidationResultRepository validationResultRepository,
|
ValidationResultRepository validationResultRepository,
|
||||||
|
@ -200,12 +202,12 @@ public class ValidationController {
|
||||||
try {
|
try {
|
||||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||||
DocumentBuilder db = dbf.newDocumentBuilder();
|
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||||
CamelContext camelContext = new DefaultCamelContext();
|
|
||||||
RouteBuilder oaiPmhRouteBuilder =
|
RouteBuilder oaiPmhRouteBuilder =
|
||||||
new OaiPmhRoute("oaipmh://"+baseURL + "?verb=ListRecords&metadataPrefix=" + metadataPrefix ,
|
new OaiPmhRoute("oaipmh://"+baseURL + "?verb=ListRecords&metadataPrefix=" + metadataPrefix ,
|
||||||
profile, validationJob, numberOfRecords, validationIssueRepository, validationResultRepository);
|
profile, validationJob, numberOfRecords, validationIssueRepository, validationResultRepository);
|
||||||
camelContext.addRoutes(oaiPmhRouteBuilder);
|
camelContext.addRoutes(oaiPmhRouteBuilder);
|
||||||
camelContext.start();
|
//camelContext.start();
|
||||||
//camelContext.stop();
|
//camelContext.stop();
|
||||||
validationJob.status = "COMPLETED";
|
validationJob.status = "COMPLETED";
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.dnetlib.validatorapi.utils;
|
package eu.dnetlib.validatorapi.utils;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.usertype.UserType;
|
import org.hibernate.usertype.UserType;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -34,20 +34,21 @@ public class CustomStringArrayType implements UserType {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 {
|
throws HibernateException, SQLException {
|
||||||
Array array = rs.getArray(names[0]);
|
Array array = resultSet.getArray(names[0]);
|
||||||
return array != null ? array.getArray() : null;
|
return array != null ? array.getArray() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
|
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index,
|
||||||
throws HibernateException, SQLException {
|
SharedSessionContractImplementor sharedSessionContractImplementor) throws HibernateException, SQLException {
|
||||||
if (value != null && st != null) {
|
if (value != null && preparedStatement != null) {
|
||||||
Array array = session.connection().createArrayOf("text", (String[])value);
|
Array array = sharedSessionContractImplementor.connection().createArrayOf("text", (String[])value);
|
||||||
st.setArray(index, array);
|
preparedStatement.setArray(index, array);
|
||||||
} else {
|
} else {
|
||||||
st.setNull(index, sqlTypes()[0]);
|
preparedStatement.setNull(index, sqlTypes()[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue