feat(users): replace Thrift transport with Spring Boot REST#3993
Open
furkangomleksiz wants to merge 1 commit intoeclipse-sw360:mainfrom
Open
feat(users): replace Thrift transport with Spring Boot REST#3993furkangomleksiz wants to merge 1 commit intoeclipse-sw360:mainfrom
furkangomleksiz wants to merge 1 commit intoeclipse-sw360:mainfrom
Conversation
Migrate the users backend service from Apache Thrift over HTTP to a standalone Spring Boot application exposing a conventional REST API. This is a proof-of-concept for the full Thrift removal (GSoC project "Remove Apache Thrift and Migrate to Direct Spring Service Calls"). Changes ------- - Delete UserServlet.java (TServlet subclass) and WEB-INF/web.xml - Remove 'implements UserService.Iface' and all 'throws TException' from UserHandler; narrow exception signatures to SW360Exception only where actually thrown - Add UserRestController (@RestController) mapping all UserHandler methods to REST endpoints under /users/** - Add UserSpringApplication (@SpringBootApplication) and UserServiceConfig (@configuration) for Spring Boot wiring - Change backend/users packaging from WAR to executable JAR; runs on port 8090 by default (sw360.users-service-url property) - Replace Sw360UserService THttpClient/TCompactProtocol transport with RestTemplate; remove all getThriftUserClient() call sites - Add PagedUsersResult DTO in datahandler to replace the awkward Map<PaginationData,List<User>> return type for REST serialization - Add request DTOs (UserSearchRequest, UserExactSearchRequest, DeleteUserRequest, UpdateDepartmentRequest) for multi-param endpoints Intentionally out of scope -------------------------- - Data model (User, PaginationData, SW360Exception) still uses Thrift-generated POJOs; replacing them requires migrating User._Fields usages in UserController (separate follow-up) - syncUser / synchronizeUserWithDatabase still use ThriftClients and are marked @deprecated(forRemoval=true) Operator change: add sw360.users-service-url=http://<host>:8090 to resource-server application.properties and run backend-users as a standalone JAR instead of deploying users.war to Tomcat. Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pilot migration of the
usersbackend service away from Apache Thrifttoward a plain Spring Boot REST architecture, as proposed in the GSoC
idea "Remove Apache Thrift and Migrate to Direct Spring Service Calls".
Closes: (leave empty or link to the GSoC issue if one exists)
What changed
backend/usersUserServlet.java— the ThriftTServletthat exposedUserHandlerover binary Thrift protocolWEB-INF/web.xml— the servlet mapping for the Thriftendpoint
UserRestController.java—@RestControllerexposing allUserHandlermethods as REST endpoints under/users/**UserSpringApplication.java—@SpringBootApplicationentry point so the module runs as a standalone executable JAR
UserServiceConfig.java—@Configurationthat wiresUserHandleras a Spring bean (constructor throwsIOException,so direct
@Serviceis not possible)application.properties— setsserver.port=8090,disables security auto-config for this internal service
UserSearchRequest,UserExactSearchRequest,DeleteUserRequest,UpdateDepartmentRequest— clean requestbodies replacing Thrift's multi-arg RPC calls
UserHandler.java— removedimplements UserService.Iface,removed all
throws TException(replaced withthrows SW360Exceptionwhere actually thrown, removed where not needed)
pom.xml— changed packagingwar→jar, addedspring-boot-starter-webandspring-boot-maven-pluginlibraries/datahandlerPagedUsersResult.java— DTO replacing the awkwardMap<PaginationData, List<User>>Thrift return type with a flatJSON-serialisable structure
rest/resource-serverSw360UserService.java— replaced allThriftClients/THttpClientcalls withRestTemplatecalls targeting the newSpring Boot users service (
http://localhost:8090by default).Two methods that still use
ThriftClients(syncUser,synchronizeUserWithDatabase) are marked@Deprecated(forRemoval=true)with TODO comments for the next phase.
Architecture
Before: UserController → Sw360UserService → THttpClient → users.war (Thrift)
After: UserController → Sw360UserService → RestTemplate → users.jar (Spring Boot REST)
The data model (
User,PaginationData,SW360Exception) is kept asThrift-generated for now to keep this PR focused on the transport layer.
Full POJO migration is a follow-up.
Local testing
docker compose up -d— all three services started successfully(
sw360,couchdb,couchdb_nouveau)http://localhost:8080/users/returns HTTP 200http://localhost:8080/health/returns HTTP 200Out of scope / follow-ups
syncUser/synchronizeUserWithDatabaseoffThriftClients