Skip to content

Refactor: Introduce service layer and thin down controller layer#207

Open
anderslindho wants to merge 6 commits intoChannelFinder:masterfrom
anderslindho:thin-controller
Open

Refactor: Introduce service layer and thin down controller layer#207
anderslindho wants to merge 6 commits intoChannelFinder:masterfrom
anderslindho:thin-controller

Conversation

@anderslindho
Copy link
Copy Markdown
Contributor

Moves towards a clean controller -> service -> repository layering as the foundation for a future versioned REST API.

- Add LegacyApiProperties @ConfigurationProperties bean for channelfinder.legacy.service-root,
  normalizing leading/trailing slashes; defaults to ChannelFinder.
- Remove hardcoded CFResourceDescriptors constants from all six API interface @RequestMapping
  declarations; interfaces now carry only HTTP method contracts.
- Inject scroll resource URI via @value in ChannelRepository to avoid static constant coupling.
- Document the property in application.properties.
…egation

All business logic (authorization, validation, orchestration) moves out of controllers
into dedicated application services. Controllers now contain only constructor injection
and single-line delegation calls.

- Add ChannelService, TagService, PropertyService, InfoService, ChannelScrollService.
- Move processAllChannels scroll orchestration and CF_ADMIN auth check into
  ChannelProcessorService; remove IChannelScroll dependency from its controller.
- Add seven domain exception types (ChannelNotFoundException, TagNotFoundException,
  PropertyNotFoundException, *ValidationException, UnauthorizedException).
- Add ChannelFinderExceptionHandler (@RestControllerAdvice) mapping domain exceptions
  to HTTP status codes.
- Remove validateChannelRequest/validateTagRequest/validatePropertyRequest from API
  interfaces; validation now lives entirely in the service layer.
- Switch all six controllers to constructor injection.
- Update ChannelProcessorServiceTest to match the expanded constructor signature.
Introduce a web package hierarchy that makes the structural intent clear
and leaves room for a future web.v1 package alongside it.

- rest.api.* -> web.legacy.api.*
- rest.controller.* -> web.legacy.controller.*
- ChannelFinderExceptionHandler -> web (cross-cutting, not legacy-specific)

Update all test imports accordingly. No behaviour change.
Replace the implicit per-controller @crossorigin annotations with an
explicit CorsConfigurationSource bean in WebSecurityConfig, backed by a
configurable cors.allowed-origins property (default: *).

- Remove @crossorigin from all legacy controllers (committed as fixup).
- Add corsConfigurationSource() bean and wire it into the filter chain.
- Document the property in application.properties.
…n errors

Bulk requests of 1500+ channels with rich property payloads exceeded the
default ES circuit-breaker limit (~102 MiB), causing 429/413 rejections in
CI. Split channel inserts into batches of 1000 and throw on bulk errors
rather than logging and continuing with a silently empty index.

Same fail-fast treatment applied to checkBulkResponse (properties/tags).
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 2, 2026

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.

1 participant