Revision f1a25720
Added by Katja Luther over 6 years ago
- ID f1a25720755daa96e8838a617a660dfced7b9f31
- Parent 23e50194
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/hibernate/CdmPreDataChangeListener.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.persistence.hibernate; |
10 | 10 |
|
11 |
import java.time.ZonedDateTime; |
|
12 |
|
|
11 | 13 |
import org.hibernate.event.spi.PreInsertEvent; |
12 | 14 |
import org.hibernate.event.spi.PreInsertEventListener; |
13 | 15 |
import org.hibernate.event.spi.PreUpdateEvent; |
14 | 16 |
import org.hibernate.event.spi.PreUpdateEventListener; |
15 |
import org.joda.time.DateTime; |
|
16 | 17 |
import org.springframework.security.core.Authentication; |
17 | 18 |
import org.springframework.security.core.context.SecurityContextHolder; |
18 | 19 |
|
... | ... | |
45 | 46 |
Object entity = event.getEntity(); |
46 | 47 |
if (VersionableEntity.class.isAssignableFrom(entity.getClass())) { |
47 | 48 |
VersionableEntity versionableEntity = (VersionableEntity)entity; |
48 |
versionableEntity.setUpdated(new DateTime());
|
|
49 |
versionableEntity.setUpdated(ZonedDateTime.now());
|
|
49 | 50 |
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); |
50 | 51 |
if(authentication != null && authentication.getPrincipal() != null && authentication.getPrincipal() instanceof User) { |
51 | 52 |
User user = (User)authentication.getPrincipal(); |
... | ... | |
67 | 68 |
ICdmBase cdmBase = (ICdmBase)entity; |
68 | 69 |
|
69 | 70 |
if (cdmBase.getCreated() == null){ |
70 |
cdmBase.setCreated(new DateTime());
|
|
71 |
cdmBase.setCreated(ZonedDateTime.now());
|
|
71 | 72 |
} |
72 | 73 |
if(cdmBase.getCreatedBy() == null) { |
73 | 74 |
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); |
Also available in: Unified diff
first implementation for change from joda time to java8 time