...
 
Commits (2)
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<parent> <parent>
<groupId>org.genesys-pgr</groupId> <groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks-parent</artifactId> <artifactId>application-blocks-parent</artifactId>
<version>1.5</version> <version>2.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath> <relativePath>../parent/pom.xml</relativePath>
</parent> </parent>
<artifactId>application-blocks-auditlog</artifactId> <artifactId>application-blocks-auditlog</artifactId>
...@@ -79,13 +79,13 @@ ...@@ -79,13 +79,13 @@
<dependency> <dependency>
<groupId>org.genesys-pgr</groupId> <groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks-security</artifactId> <artifactId>application-blocks-security</artifactId>
<version>1.5</version> <version>2.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.genesys-pgr</groupId> <groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks-core</artifactId> <artifactId>application-blocks-core</artifactId>
<version>1.5</version> <version>2.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -52,6 +52,7 @@ import org.hibernate.CallbackException; ...@@ -52,6 +52,7 @@ import org.hibernate.CallbackException;
import org.hibernate.EmptyInterceptor; import org.hibernate.EmptyInterceptor;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.resource.transaction.spi.TransactionStatus;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -715,7 +716,7 @@ public class AuditTrailInterceptor extends EmptyInterceptor implements Initializ ...@@ -715,7 +716,7 @@ public class AuditTrailInterceptor extends EmptyInterceptor implements Initializ
currentAuditLogs.stream().forEach(auditLog -> { currentAuditLogs.stream().forEach(auditLog -> {
LOG.debug("Audit log to save: {}", auditLog); LOG.debug("Audit log to save: {}", auditLog);
}); });
if (tx.wasRolledBack()) { if (tx.getStatus().equals(TransactionStatus.ROLLED_BACK)) {
LOG.warn("Transaction was rolled back. Audit logs likely won't be persisted"); LOG.warn("Transaction was rolled back. Audit logs likely won't be persisted");
} }
this.auditTrailService.addAuditLogs(currentAuditLogs); this.auditTrailService.addAuditLogs(currentAuditLogs);
...@@ -742,9 +743,9 @@ public class AuditTrailInterceptor extends EmptyInterceptor implements Initializ ...@@ -742,9 +743,9 @@ public class AuditTrailInterceptor extends EmptyInterceptor implements Initializ
final long level = auditLogStack.get().size(); final long level = auditLogStack.get().size();
LOG.trace("afterTransactionCompletion transaction level={}", level); LOG.trace("afterTransactionCompletion transaction level={}", level);
if (tx.wasCommitted()) { if (tx.getStatus().equals(TransactionStatus.COMMITTED)) {
LOG.trace("Transaction was committed, level={}", level); LOG.trace("Transaction was committed, level={}", level);
} else if (tx.wasRolledBack()) { } else if (tx.getStatus().equals(TransactionStatus.ROLLED_BACK)) {
LOG.trace("Transaction was rolled back, level={}", level); LOG.trace("Transaction was rolled back, level={}", level);
} }
......
...@@ -20,7 +20,7 @@ import static org.hamcrest.Matchers.hasSize; ...@@ -20,7 +20,7 @@ import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat; import static org.junit.Assert.*;
import java.util.List; import java.util.List;
...@@ -165,6 +165,7 @@ public class AuditTrailServiceTest extends ServiceTest { ...@@ -165,6 +165,7 @@ public class AuditTrailServiceTest extends ServiceTest {
try { try {
entity.setName("Test 1. This is too long and should fail."); entity.setName("Test 1. This is too long and should fail.");
entity = exampleAuditedEntityService.save(entity); entity = exampleAuditedEntityService.save(entity);
fail("Expected " + DataIntegrityViolationException.class + " exception.");
} catch (DataIntegrityViolationException e) { } catch (DataIntegrityViolationException e) {
// Name is too long // Name is too long
assertThat(listAuditLogs(entity), hasSize(1)); assertThat(listAuditLogs(entity), hasSize(1));
......
...@@ -37,7 +37,7 @@ import org.springframework.dao.support.PersistenceExceptionTranslator; ...@@ -37,7 +37,7 @@ import org.springframework.dao.support.PersistenceExceptionTranslator;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.hibernate4.HibernateExceptionTranslator; import org.springframework.orm.hibernate5.HibernateExceptionTranslator;
import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
...@@ -140,7 +140,7 @@ public class DatabaseConfig { ...@@ -140,7 +140,7 @@ public class DatabaseConfig {
// LOG.trace("JPA: " + key + " = " + jpaProperties.get(key)); // LOG.trace("JPA: " + key + " = " + jpaProperties.get(key));
// } // }
jpaProperties.put("hibernate.ejb.interceptor", new EmptyInterceptor() { jpaProperties.put("hibernate.session_factory.interceptor", new EmptyInterceptor() {
private static final long serialVersionUID = 412280557897728434L; private static final long serialVersionUID = 412280557897728434L;
// NOTE We're using the auditTrailInterceptor() to fetch the lazy-initialized // NOTE We're using the auditTrailInterceptor() to fetch the lazy-initialized
......
...@@ -24,3 +24,4 @@ hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFa ...@@ -24,3 +24,4 @@ hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFa
hibernate.cache.use_structured_entries=false hibernate.cache.use_structured_entries=false
hibernate.generate_statistics=false hibernate.generate_statistics=false
hibernate.id.new_generator_mappings=false
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<parent> <parent>
<groupId>org.genesys-pgr</groupId> <groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks-parent</artifactId> <artifactId>application-blocks-parent</artifactId>
<version>1.5</version> <version>2.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath> <relativePath>../parent/pom.xml</relativePath>
</parent> </parent>
<artifactId>application-blocks-core</artifactId> <artifactId>application-blocks-core</artifactId>
...@@ -81,21 +81,21 @@ ...@@ -81,21 +81,21 @@
<version>${spring.version}</version> <version>${spring.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.tomcat</groupId> <groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId> <artifactId>tomcat-jdbc</artifactId>
<version>7.0.42</version> <version>7.0.42</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.hsqldb</groupId> <groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId> <artifactId>hsqldb</artifactId>
<version>${hsqldb.version}</version> <version>${hsqldb.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId> <artifactId>spring-aspects</artifactId>
......
...@@ -28,7 +28,7 @@ import org.springframework.dao.support.PersistenceExceptionTranslator; ...@@ -28,7 +28,7 @@ import org.springframework.dao.support.PersistenceExceptionTranslator;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.hibernate4.HibernateExceptionTranslator; import org.springframework.orm.hibernate5.HibernateExceptionTranslator;
import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<parent> <parent>
<groupId>org.genesys-pgr</groupId> <groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks</artifactId> <artifactId>application-blocks</artifactId>
<version>1.5</version> <version>2.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>application-blocks-parent</artifactId> <artifactId>application-blocks-parent</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
...@@ -40,17 +40,15 @@ ...@@ -40,17 +40,15 @@
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version> <nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
<aspectj.version>1.7.2</aspectj.version> <jackson.version>2.9.8</jackson.version>
<jackson.version>2.7.7</jackson.version> <spring.version>4.3.22.RELEASE</spring.version>
<spring.version>4.3.2.RELEASE</spring.version> <spring.data.version>1.11.18.RELEASE</spring.data.version>
<spring.data.version>1.10.4.RELEASE</spring.data.version> <spring.security.oauth2.version>2.3.3.RELEASE</spring.security.oauth2.version>
<spring.security.oauth2.version>2.0.11.RELEASE</spring.security.oauth2.version>
<querydsl.version>4.1.4</querydsl.version> <querydsl.version>4.1.4</querydsl.version>
<spring.security.version>4.1.3.RELEASE</spring.security.version> <spring.security.version>4.2.11.RELEASE</spring.security.version>
<hibernate.version>4.3.11.Final</hibernate.version> <hibernate.version>5.2.17.Final</hibernate.version>
<hsqldb.version>2.4.0</hsqldb.version> <hsqldb.version>2.4.1</hsqldb.version>
<tomcat-jdbc.version>8.5.8</tomcat-jdbc.version> <tomcat-jdbc.version>8.5.8</tomcat-jdbc.version>
<ehcache.version>2.7.4</ehcache.version>
</properties> </properties>
<repositories> <repositories>
...@@ -185,7 +183,7 @@ ...@@ -185,7 +183,7 @@
<dependency> <dependency>
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId> <artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version> <version>${hibernate.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.genesys-pgr</groupId> <groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks</artifactId> <artifactId>application-blocks</artifactId>
<version>1.5</version> <version>2.0-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Application Building Blocks</name> <name>Application Building Blocks</name>
<description>This is the shared project pom.</description> <description>This is the shared project pom.</description>
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
<connection>scm:https://gitlab.croptrust.org/genesys-pgr/application-blocks</connection> <connection>scm:https://gitlab.croptrust.org/genesys-pgr/application-blocks</connection>
<developerConnection>scm:git:git@gitlab.croptrust.org:genesys-pgr/application-blocks.git</developerConnection> <developerConnection>scm:git:git@gitlab.croptrust.org:genesys-pgr/application-blocks.git</developerConnection>
<url>git@gitlab.croptrust.org:genesys-pgr/application-blocks.git</url> <url>git@gitlab.croptrust.org:genesys-pgr/application-blocks.git</url>
<tag>application-blocks-1.5</tag> <tag>HEAD</tag>
</scm> </scm>
<issueManagement> <issueManagement>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<parent> <parent>
<groupId>org.genesys-pgr</groupId> <groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks-parent</artifactId> <artifactId>application-blocks-parent</artifactId>
<version>1.5</version> <version>2.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath> <relativePath>../parent/pom.xml</relativePath>
</parent> </parent>
<artifactId>application-blocks-security</artifactId> <artifactId>application-blocks-security</artifactId>
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
<dependency> <dependency>
<groupId>org.genesys-pgr</groupId> <groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks-core</artifactId> <artifactId>application-blocks-core</artifactId>
<version>1.5</version> <version>2.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
<version>${spring.security.version}</version> <version>${spring.security.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId> <artifactId>spring-security-test</artifactId>
...@@ -155,7 +155,7 @@ ...@@ -155,7 +155,7 @@
<dependency> <dependency>
<groupId>com.fasterxml.jackson.datatype</groupId> <groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate4</artifactId> <artifactId>jackson-datatype-hibernate5</artifactId>
<version>${jackson.version}</version> <version>${jackson.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
......
...@@ -29,7 +29,7 @@ import org.springframework.dao.support.PersistenceExceptionTranslator; ...@@ -29,7 +29,7 @@ import org.springframework.dao.support.PersistenceExceptionTranslator;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.hibernate4.HibernateExceptionTranslator; import org.springframework.orm.hibernate5.HibernateExceptionTranslator;
import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
......
...@@ -20,7 +20,7 @@ import java.util.List; ...@@ -20,7 +20,7 @@ import java.util.List;
import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
import org.genesys.blocks.security.test.ServiceTest; import org.genesys.blocks.security.test.ServiceTest;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -65,7 +65,7 @@ public abstract class AbstractRestTest extends ServiceTest { ...@@ -65,7 +65,7 @@ public abstract class AbstractRestTest extends ServiceTest {
final MappingJackson2HttpMessageConverter messageConverter = new MappingJackson2HttpMessageConverter(); final MappingJackson2HttpMessageConverter messageConverter = new MappingJackson2HttpMessageConverter();
final ObjectMapper mapper = new ObjectMapper(); final ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new Hibernate4Module()); mapper.registerModule(new Hibernate5Module());
// serialization // serialization
mapper.disable(SerializationFeature.EAGER_SERIALIZER_FETCH); mapper.disable(SerializationFeature.EAGER_SERIALIZER_FETCH);
// deserialization // deserialization
......