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>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.5.22.RELEASE</version>
|
||||
<version>2.7.10</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
|||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<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-->
|
||||
<!--swagger-version>2.7.0</swagger-version-->
|
||||
</properties>
|
||||
|
@ -64,13 +65,25 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-core</artifactId>
|
||||
<version>3.20.5</version>
|
||||
<version>${apache.camel.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-oaipmh</artifactId>
|
||||
<version>3.20.5</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>
|
||||
|
|
|
@ -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.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,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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue