Commit Graph

59 Commits

Author SHA1 Message Date
Mark Paluch
d3af4a79e4 DATACMNS-1231 - Add reactive auditing infrastructure.
We now provide a reactive variant for auditing with ReactiveAuditingHandler and ReactiveIsNewAwareAuditingHandler.

Extracted common auditing functionality into AuditingHandlerSupport which serves as base class for AuditingHandler and ReactiveAuditingHandler.

Original Pull Request: #458
2020-07-17 10:14:10 +02:00
Phillip Webb
86bda64daa DATACMNS-1755 - Declare each variable in its own statement.
Update classes so that each member is declared on its own line. This
help to make them slightly easier to see when not using an IDE.

Original pull request: #448.
2020-06-25 11:20:28 +02:00
Phillip Webb
67442077b7 DATACMNS-1755 - Consistently use commons-logging.
Replace the few occurrences where SLF4J was being used directly so that
all logging now happens via commons-logging. The log patterns used in
SLF4J messages have been replaced with `LogMessage` which was introduced
in Spring Framework 5.2.

Original pull request: #448.
2020-06-25 11:20:24 +02:00
Phillip Webb
b42cdb6568 DATACMNS-1755 - Use method references in favor of lambdas.
Simplify several lambda expressions in the codebase by using
method references.

Original pull request: #448.
2020-06-25 11:19:52 +02:00
Phillip Webb
cb8443e299 DATACMNS-1755 - Rename uppercase 'CACHE' static finals.
Rename static final `CACHE` members to use the lowercase form. Although
the caches are static final, they are not constant values.

Original pull request: #448.
2020-06-25 11:19:44 +02:00
Phillip Webb
ea263b233b Rename uppercase 'LOGGER' static finals
Rename static final `LOGGER` members to use the lowercase form.
Although the loggers are static final, they are not constant values.
2020-06-25 11:09:16 +02:00
Mark Paluch
4be5aae181 DATACMNS-1726 - Delombok source files. 2020-05-15 08:46:58 +02:00
Mark Paluch
7de360cb7b DATACMNS-1676 - Polishing.
Encapsulate field and introduce getter for ConversionService. Add missing Override annotation. Add author tags. Minor cleanups.

Original pull request: #432.
2020-05-12 10:42:01 +02:00
Pavel Horal
f2f7886105 DATACMNS-1676 - Create shared conversion service for AuditableBeanWrapper.
Prevent performance penalty in creating conversion service each time a domain object is being persisted.

Original pull request: #432.
2020-05-12 10:41:27 +02:00
Oliver Drotbohm
5cdb3139a4 DATACMNS-1610 - Improved property path access.
We now expose a dedicated PersistentPropertyPathAccessor and optionally take options for both the read and write access to properties. On read, clients can define to eagerly receive null in case one of the path segments is null. By default, we reject those as it indicates that there might be an issue with the backing object if the client assumes it can look up the more deeply nested path to receive a result.

On write access clients can define to either reject, skip or log intermediate null segments where skip means, that the setting is just silently aborted. Clients can also control how to deal with collection and map intermediates. By default we now propagate the attempt to set a value to all collection or map items respectively. This could be potentially extended to provide a filter receiving both the property and property value to selectively propagate those calls in the future.

The separation of these APIs (PersistentPropertyAccessor and PersistentPropertyPathAccessor) is introduced as the latter can be implemented on top of the former and the former potentially being dynamically generated. The logic of the latter can then be clearly separated from the actual individual property lookup. ConvertingPropertyAccessor is now a PersistentPropertyPathAccessor, too, and overrides SimplePersistentPropertyPathAccessor.getTypedProperty(…) to plug in conversion logic. This allows custom collection types being used if the ConversionService backing the accessor can convert from and to Collection or Map respectively.

Deprecated all PersistentPropertyPath-related methods on PersistentPropertyAccessor for removal in 2.3.

MappingAuditableBeanWrapperFactory now uses these new settings to skip both null values as well as collection and map values when setting auditing metadata.

Related tickets: DATACMNS-1438, DATACMNS-1461, DATACMNS-1609.
2020-02-03 13:11:44 +01:00
Mark Paluch
eed7658ce5 DATACMNS-1643 - Update copyright years to 2020. 2020-01-07 08:32:25 +01:00
Oliver Drotbohm
ced3dde2a4 DATACMNS-1609, DATACMNS-1438 - Skip collection path segments for auditing properties.
We now skip PersistentPropertyPath instances pointing to auditing properties for which the path contains a collection or map path segment as the PersistentPropertyAccessor currently cannot handle those. A more extensive fix for that will be put in place for Moore but requires more extensive API changes which we don't want to ship in a Lovelace maintenance release.

Related tickets: DATACMNS-1461.
2019-11-11 10:45:18 +01:00
Oliver Drotbohm
e28a78ee8e DATACMNS-1609, DATACMNS-1461 - Polishing. 2019-11-11 10:45:14 +01:00
Oliver Drotbohm
71a42664c2 DATACMNS-1609, DATACMNS-1461 - Handle null intermediates in setting auditing property paths.
We now catch the MappingException produced by trying to set auditing property paths containing null intermediate segments and ignore those. A less expensive (non-Exception-based) approach is going to be introduced for Moore as it requires API changes to the property path setting APIs.

Related tickets: DATACMNS-1438.
2019-11-11 10:45:08 +01:00
Michael Simons
38b08f4e27 DATACMNS-1548 - Fix JavaDoc on AuditingHandler#setModifyOnCreation.
Original pull request: #397.
2019-06-24 10:54:39 +02:00
Spring Operator
48c9297118 DATACMNS-1500 - URL Cleanup.
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# Fixed URLs

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* [ ] http://www.apache.org/licenses/ with 1 occurrences migrated to:
  https://www.apache.org/licenses/ ([https](https://www.apache.org/licenses/) result 200).
* [ ] http://www.apache.org/licenses/LICENSE-2.0 with 701 occurrences migrated to:
  https://www.apache.org/licenses/LICENSE-2.0 ([https](https://www.apache.org/licenses/LICENSE-2.0) result 200).

Original Pull Request: #387
2019-03-22 11:00:44 +01:00
Mark Paluch
1969f4bcdc DATACMNS-1459 - Update copyright years to 2019. 2019-01-02 12:12:19 +01:00
Francisco Soler
789099f6b9 DATACMNS-1453 - Fixed wrong assertion in AuditingBeanDefinitionRegistrarSupport.
Original pull request: #328.
2018-12-20 15:52:06 +01:00
Yuki Yoshida
aa3ed766b5 DATACMNS-1387 - Fix JavaDoc in CurrentDateTimeProvider and remove unused import. 2018-09-07 13:21:47 +02:00
Oliver Gierke
1f4d494f83 DATACMNS-1322 - Generified PersistentPropertyAccessor API.
PersistentPropertyAccessor is now generic to be able to retain the type information about the object it was created for and the return type of ….getBean(). Adapted client APIs.
2018-07-12 10:23:17 +02:00
Oliver Gierke
6cb3587ba3 DATACMNS-1322 - Adapt auditing handler API to support immutable entities.
We've changed the APIs in the auditing subsystem so that we support immutable entities, mostly through MappingAuditableBeanWrapperFactory that uses a PersistentPropertyAccessor.
2018-07-04 16:59:51 +02:00
Oliver Gierke
fc2135df3d DATACMNS-1333 - Unified is-new-detection in PersistentEntity.isNew(…).
PersistentEntity now exposes an ….isNew(…) method that exposes the same detection algorithm previously exposed through MappingContextIsNewStrategyFactory (Persistable in favor of the version property in favor of an identifier lookup). MappingContextIsNewStrategyFactory  has been refactored to return an ad-hoc strategy to delegate to the newly introduced method.

The core message to implementing modules is that they should now prefer PersistentEntityInformation within their RepositoryFactorySupport implementation and move all customizations made in the store-specific EntityInformation implementation in PersistentEntity.
2018-06-01 13:50:28 +02:00
Oliver Gierke
7ab2c84ea8 DATACMNS-1318 - Polishing.
Moved to newly introduced varargs-based factory method for PersistentEntities where applicable.
2018-05-30 21:39:56 +02:00
Oliver Gierke
170c25d355 DATACMNS-1274 - Auditing now can set metadata in nested objects.
Based on the new infrastructure created by DATACMNS-1275, MappingAuditingMetadata now keeps PersistentPropertyPaths to point to the properties reflecting individual auditing metadata items rather than just PersistentPropertyPaths. With that in place we can now find those items in embedded types of the subject entity based on the detection setup of the MappingContext managing metadata for the entity.

As that means that multiple paths to a metadata item property can be found, we now use the first path found (the shortest one) for the lookup of the modification date.

Related tickets: DATACMNS-1275.
2018-04-09 14:31:20 +02:00
Oliver Gierke
73103f3551 DATACMNS-1281 - Fixed potential concurrency issue in MappingAuditableBeanWrapperFactory.
We now use a ConcurrentReferenceHashMap to cache the metadata calculated to prevent ConcurrentModificationExceptions getBeanWrapperFor(…).
2018-03-27 15:59:14 +02:00
Oliver Gierke
6675e33233 DATACMNS-1259 - Polishing.
Removed unnecessary imports. Tiny refactoring to pull exception creation into static helper method. Made methods static in test cases where possible.

Original pull request: #273.
2018-02-15 14:31:33 +01:00
Jens Schauder
9d3540cc54 DATACMNS-1259 - Polishing.
Refactored lambdas to method references. Simplified type parameter. Added comment to test to indicate related issue.

Original pull request: #273.
2018-02-15 14:31:33 +01:00
Jens Schauder
5251f72e69 DATACMNS-1259 - Fixed support for Long values in Auditables.
Using Instant as internal data type since it's a point in time without time zone which LocalDateTime isn't. Added necessary converters. Fixed one JodaTime converter that used UTC to use SystemDefault like other similar converters.

In case of a conversion failure the error message now contains the source type.

Original pull request: #273.
2018-02-15 14:31:33 +01:00
Mark Paluch
51e7e1b7f5 DATACMNS-1240 - Update copyright years to 2018.
Also, remove some trailing whitespaces and align outdated license header format.
2018-01-08 16:04:34 +01:00
Oliver Gierke
049970874d DATACMNS-1114 - Introduced usage of nullable annotations for API validation.
Marked all packages with Spring Frameworks @NonNullApi. Added Spring's @Nullable to methods, parameters and fields that take or produce null values. Adapted using code to make sure the IDE can evaluate the null flow properly. Fixed Javadoc in places where an invalid null handling policy was advertised. Strengthened null requirements for types that expose null-instances.

Removed null handling from converters for JodaTime and ThreeTenBP. Introduced factory methods Page.empty() and Page.empty(Pageable). Introduced default methods getRequiredGetter(), …Setter() and …Field() on PersistentProperty to allow non-nullable lookups of members. The same for TypeInformation.getrequiredActualType(), …SuperTypeInformation().

Tweaked PersistentPropertyCreator.addPropertiesForRemainingDescriptors() to filter unsuitable PropertyDescriptors before actually trying to create a Property instance from them as the new stronger nullability requirements would cause exceptions downstream.

Lazy.get() now expects a non-null return value. Clients being able to cope with null need to call ….orElse(…).

Original pull request: #232.
2017-07-24 10:47:28 +02:00
Oliver Gierke
6a6d995eab DATACMNS-1109 - Reinstantiate support for all date/time APIs in auditing.
Re-enabled test cases for handling of different date/time APIs in auditing. Tweaked the lookup of the last modified value to try to convert to LocalDateTime as well in case it's a subtype of the type requested. In combination with two newly introduced converters for local date type times in JodaTime and ThreeTenBP, this allows us to still convert legacy JodaTime and ThreeTenBP types to be used as well.
2017-07-12 19:17:23 +02:00
Oliver Gierke
09dd13c41a DATACMNS-1101 - Adapt API changes in PropertyAccessor from MappingAuditableBeanWrapperFactory.
We now avoid wrapping the value into an Optional as PropertyAccessor now takes Object as parameter right away.
2017-07-04 14:30:45 +02:00
Mark Paluch
6c65c02e78 DATACMNS-1101 - Remove Optional from mapping/convert use except for caching of absence and computations that are used to populate caches. 2017-07-04 14:30:42 +02:00
Mark Paluch
74fbe13f54 DATACMNS-1101 - Reduce Optional usage in convert/mapping packages.
Reducing Optional usage that lies on hot code paths for object mapping.
2017-07-04 14:30:42 +02:00
Oliver Gierke
93bb3d2e21 DATACMNS-867 - Additional assertions in AuditingHandler. 2017-03-24 08:00:47 +01:00
Oliver Gierke
58b2bde303 DATACMNS-867 - Removed Optionals from Auditing methods signatures. 2017-03-24 08:00:46 +01:00
Oliver Gierke
082c4157d1 DATACMNS-867 - Less Optional for auditing subsystem.
Removed Optional<Object> parameters in favor of plain Object and clients that avoid calling methods for absent values in the first place.
2017-03-24 08:00:45 +01:00
Christoph Strobl
be347eaaab DATACMNS-867 - Additional Java 8 language feature cleanup.
Make use of lambdas and method references though out the codebase. Remove no longer required generic type parameters.
Additionally remove unused imports and replace single element list initialization with dedicated singletonList.
Use Assertion overloads taking Supplier for dynamic assertion error messages.
2017-03-24 08:00:43 +01:00
Christoph Strobl
d363e8f2c2 DATACMNS-867 - Favor LocalDateTime over ZonedDateTime in CurrentDateTimeProvider.
Use LocalDateTime to avoid timezone issues just because the default auditing cannot handle it when the domain type property comes from eg. jodatime.
2017-03-24 08:00:43 +01:00
Oliver Gierke
d4811e29d9 DATACMNS-867 - Second draft. 2017-03-24 08:00:23 +01:00
Oliver Gierke
cc63e5b7a4 DATACMNS-867 - First draft. 2017-03-24 08:00:23 +01:00
Christoph Strobl
3e048a6dca DATACMNS-985 - Remove references to single-argument assertion methods. 2017-01-31 18:10:40 +01:00
Oliver Gierke
e3b7bb8b01 DATACMNS-957 - AuditingHandler now works with entities without an identifier.
Entities without an identifier previously an exception because the IsNewStrategyFactory wasn't able to determine a strategy even if there was no auditing to be applied in the first place.

We now eagerly check for auditability and skip the lookup for an IsNewStrategy completely in case that check returns false.

Related pull request: #189.
2017-01-19 09:50:11 +01:00
Oliver Gierke
9dc581df43 DATACMNS-738 - Removed deprecations in BeanWrapper.
Removed deprecated static factory method and made the class package protected.
2015-08-03 15:34:47 +02:00
Oliver Gierke
d48fddf9e6 DATACMNS-681 - Removed some compiler warnings.
Removed unused constants. Removed usage of deprecated method in RepositoryBeanDefinitionParser.
2015-04-13 13:04:59 +02:00
Oliver Gierke
0c65c7bb67 DATACMNS-638, DATACMNS-643 - Support for JSR-310 and ThreeTen datetime types.
Extend AuditableBeanWrapper to allow access to the last modification date of a target object. Made AuditableBeanWrapperFactory an interface and renamed what’s been previously known under this name as DefaultAuditableBeanWrapperFactory.

The components previously relying on a MappingContext to lookup a PersistentEntity now use PersistentEntities to be able to back a collection of MappingContexts behind that and also avoid unmanaged types to be added to the MappingContext.

We now also register the JSR-310 and ThreeTen back-port converters with the ConversionService to be able to get and set auditing dates as these types.
2015-02-04 19:30:02 +01:00
Oliver Gierke
e1b38faee9 DATACMNS-601 - Fixes for most of the SonarQube warnings. 2014-11-26 09:25:14 +01:00
Oliver Gierke
6a849bc8ef DATACMNS-596 - Introduced PersistentPropertyAccessor.
To be able to customize the lookup of bean properties by persistent store we now expose a getPropertyAccessor(Object entity) method on PersistentEntity. It returns a PersistentPropertyAccessor which is basically an interface with a simplified API of BeanWrapper.

Reduced the plain BeanWrapper to not perform any type conversion to be able to drop the ConversionService dependency. To compensate for that we introduced a ConvertingPropertyAccessor that takes a ConversionService and delegates to a standard PersistentPropertyAccessor and applies conversions if necessary.

Refactored client APIs to use the PersistentPropertyAccessor instead of referring to BeanWrapper directly. Deprecated BeanWrapper.create(…) for removal in RC1.
2014-11-18 12:29:30 +01:00
Oliver Gierke
3660676338 DATACMNS-558 - Some code cleanups according to the Sonar report. 2014-08-10 12:51:28 +02:00
Oliver Gierke
ed0f7c51f8 DATACMNS-469 - Removed deprecations. 2014-07-16 11:53:20 +02:00