Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to provide custom UriToEntityConverter #2277

Open
wants to merge 1 commit into
base: 3.7.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,13 @@ public PersistentEntities persistentEntities() {

@Bean
@Qualifier
public DefaultFormattingConversionService defaultConversionService(PersistentEntities persistentEntities,
RepositoryInvokerFactory repositoryInvokerFactory, Repositories repositories) {
public DefaultFormattingConversionService defaultConversionService() {

DefaultFormattingConversionService conversionService = (DefaultFormattingConversionService) defaultConversionService;

// Add Spring Data Commons formatters
conversionService
.addConverter(new UriToEntityConverter(persistentEntities, repositoryInvokerFactory, repositories));
.addConverter(uriToEntityConverter());
conversionService.addConverter(StringToLdapNameConverter.INSTANCE);
addFormatters(conversionService);

Expand Down Expand Up @@ -740,7 +739,7 @@ protected Module persistentEntityJackson2Module(LinkCollector linkCollector) {
LookupObjectSerializer lookupObjectSerializer = new LookupObjectSerializer(PluginRegistry.of(getEntityLookups()));

return new PersistentEntityJackson2Module(associationLinks.get(), persistentEntities.get(),
new UriToEntityConverter(persistentEntities.get(), repositoryInvokerFactory.get(), repositories.get()),
uriToEntityConverter(),
linkCollector, repositoryInvokerFactory.get(), lookupObjectSerializer, invoker.getObject(), assembler);
}

Expand Down Expand Up @@ -951,8 +950,7 @@ protected ObjectMapper basicObjectMapper() {
configurerDelegate.get().configureJacksonObjectMapper(objectMapper);

objectMapper.registerModule(geoModule.getObject());
objectMapper.registerModule(new AggregateReferenceResolvingModule(
new UriToEntityConverter(persistentEntities.get(), repositoryInvokerFactory.get(), repositories.get()),
objectMapper.registerModule(new AggregateReferenceResolvingModule(uriToEntityConverter(),
resourceMappings.get()));

if (repositoryRestConfiguration.get().isEnableEnumTranslation()) {
Expand All @@ -964,6 +962,10 @@ protected ObjectMapper basicObjectMapper() {
return objectMapper;
}

protected UriToEntityConverter uriToEntityConverter() {
return new UriToEntityConverter(persistentEntities.get(), repositoryInvokerFactory.get(), repositories.get());
}

@Bean
public EnumTranslator enumTranslator(MessageResolver resolver) {
return new EnumTranslator(resolver);
Expand Down