Skip to content

Conversation

@ngeorges-cnrs
Copy link
Contributor

This patch is an internal refactoring, which sets the ground for future work on a new internal API for a future JS frontend.
It does the following :

  • introduce a new /internal API endpoint, containing only stubs for now
  • remove vip-api.conf, now merged into vip.conf
  • no other user-visible change : /rest API and GWT UI should be strictly unchanged

Details :

  • Split the Spring WebMvc application into a context hierarchy of three, with components scanning such that each bean is in exactly one context, allowing endpoints isolation between the two APIs. The three contexts are referenced in web.xml :
    • root context in vip-core/SpringCoreConfig
    • /rest API context in vip-api/SpringRestApiConfig
    • /internal API context in vip-core/SpringInternalApiConfig
  • Add controller stubs for GET /internal/session and GET /internal/applications. For now, these new endpoints return only constant test data, and do not have authentication support yet. This illustrates that components scanning and modules separation behave as intended.
  • Move vip.api.security to vip.core.server.security (as Spring mandates that the securityFilterChain is in the root context) :
    • Move pom.xml dependencies for Spring Security and Hibernate validator from vip-api to vip-core
    • Merge vip-api.conf into vip.conf: all global settings are now in a single vip.conf file, and accessed trough the Server bean (instead of Environment). Mandatory keys are unchanged.
    • Remove test/resources/.../vip-api.conf files, and update Server mocking accordingly in tests

Decouple SpringCoreConfig from vip-api:
- Add an explicit root context in web.xml, bound to SpringCoreConfig
- Bind /rest API servlet to SpringWebConfig instead of SpringCoreConfig
- Update components scanning to have all RestController beans in
  SpringWebConfig instead of SpringCoreConfig

This will allow to add new servlets for independent new APIs.
Decoupling is not complete yet, as securityFilterChain is still
in vip-api.
Move securityFilterChain bean and its dependencies from vip-api
to vip-core.
- Move securityFilterChain (vip.api.security package) from vip.api
  to vip.core.server
- In vip-api, rename SpringWebConfig.java SpringRestApiConfig.java
- In vip-core, add a stub handler for a prototype internal api,
  currently mapped to /core

WIP: everything seems to work, but unit tests in vip-core are broken.
- Update components scanning so that it is symmetrical for /rest
  and /core. Exclude @EnableWebMvc in addition to @RestController
  to avoid recursive scan.
- Add commented out logging for components scanning.
- Make the root context (SpringCoreConfig) a WebMvc context,
  as required by having Spring Security at that level.
- Fix all tests by:
  . adjusting the context dependencies: this seems clean enough
  . making vip-api.conf optional: this is quick&dirty, should be
    a proper mock instead
- Rename /core endpoint to /internal
- Update vip-api.conf handling so that required properties are
  verified when the file is present, add some context on vip-api.conf
  optional handling. This is still "not for production", but cleaner.
vip-core/src/test/resources/vip-api.conf was added in 26c6efe
(back when tests were broken), but is not actually needed.
- CarminProperties keys are now exposed through the Server bean
  instead of Environment.
- Mandatory keys are unchanged.
- Settings are mocked in either vip-core or vip-api modules depending
  on their usage.

Everything works, but some implementation details are left todo:
define proper getters for API properties (instead of the temporary
getEnvProperty helpers), and see if cors.authorized-domains can be
moved from vip-core to vip-api.
- Rename CoreTestController to SessionController and add basic JSON
  test content
- Create an ApplicationController stub in vip-applications
- Ajust components scanning for the internal API controllers
- Rename SpringCoreApiConfig to SpringInternalApiConfig
- Rename ApiSecurityConfig to RestApiSecurityConfig
- Update scanning comments
- Remove vipConfigFolder in BaseSpringIT, now useless with mocks
Copy link
Contributor

@axlbonnet axlbonnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the spring mvc refactoring !
Just a remark about what seem to be wrong constants names.

Wrong in three places, mixed up with getCarminApiDefaultMimeType()
@axlbonnet axlbonnet merged commit e64b50c into virtual-imaging-platform:develop Oct 2, 2025
2 checks passed
@ngeorges-cnrs ngeorges-cnrs deleted the multi_api branch October 3, 2025 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants