The question is almost old, I do not know if you have found a solution.
Anywhere, you can create fully custom ALPS profiling information if you create two custom converters that replace the converters used by Spring.
The first should org.springframework.data.rest.webmvc.alps.AlpsJsonHttpMessageConverter converter org.springframework.data.rest.webmvc.alps.AlpsJsonHttpMessageConverter .
Here is a possible implementation:
public class CustomAlpsJsonHttpMessageConverter extends AlpsJsonHttpMessageConverter { public CustomAlpsJsonHttpMessageConverter(RootResourceInformationToAlpsDescriptorConverter converter) { super(converter); } @Override public boolean canWrite(Class<?> clazz, MediaType mediaType) { return super.canWrite(clazz, mediaType); } @Override public boolean canRead(Type type, Class<?> contextClass, MediaType mediaType) { return super.canRead(type, contextClass, mediaType); } @Override public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) { return super.beforeBodyWrite(body, returnType, selectedContentType, selectedConverterType, request, response); } @Override public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) { return converterType.equals(AlpsJsonHttpMessageConverter.class) || converterType.equals(CustomAlpsJsonHttpMessageConverter.class); } }
The second is org.springframework.data.rest.webmvc.alps.RootResourceInformationToAlpsDescriptorConverter converter org.springframework.data.rest.webmvc.alps.RootResourceInformationToAlpsDescriptorConverter .
RootResourceInformationToAlpsDescriptorConverter has only two public resources: the constructor and the convert method.
You can overwrite each private field / method of this class if you want to have your own behavior.
Note that the " CustomAlpsJsonHttpMessageConverter " CustomAlpsJsonHttpMessageConverter your CustomAlpsJsonHttpMessageConverter will have to match the specified "converterType" with your new CustomAlpsJsonHttpMessageConverter class.
At this point, you can customize the "convert" method of the RootResourceInformationToAlpsDescriptorConverter class by simply overriding it in your CustomRootResourceInformationToAlpsDescriptorConverter .
Finally, you must register the two converters in the application context. To do this, you can extend the RepositoryRestMvcConfiguration class, and in your CustomRepositoryRestMvcConfiguration you will need the @Override methods "alpsJsonHttpMessageConverter()" and "alpsConverter()" .
Also add the @Bean annotation in two custom ovverriding methods, for example:
@Bean @Override public AlpsJsonHttpMessageConverter alpsJsonHttpMessageConverter() { return new CustomAlpsJsonHttpMessageConverter(alpsConverter()); } @Bean @Override public RootResourceInformationToAlpsDescriptorConverter alpsConverter() { Repositories repositories = repositories(); PersistentEntities persistentEntities = persistentEntities(); RepositoryEntityLinks entityLinks = entityLinks(); MessageSourceAccessor messageSourceAccessor = resourceDescriptionMessageSourceAccessor(); RepositoryRestConfiguration config = config(); ResourceMappings resourceMappings = resourceMappings(); return new CustomRootResourceInformationToAlpsDescriptorConverter(associationLinks(), repositories, persistentEntities, entityLinks, messageSourceAccessor, config, objectMapper(), enumTranslator()); }
This way you can have fully custom ALPS if you need to.
I tried this solution to create custom profiling links and it works great.