Skip to content

feat(users): replace Thrift transport with Spring Boot REST#3993

Open
furkangomleksiz wants to merge 1 commit intoeclipse-sw360:mainfrom
furkangomleksiz:feat/migrate-users-service-thrift-to-rest
Open

feat(users): replace Thrift transport with Spring Boot REST#3993
furkangomleksiz wants to merge 1 commit intoeclipse-sw360:mainfrom
furkangomleksiz:feat/migrate-users-service-thrift-to-rest

Conversation

@furkangomleksiz
Copy link
Copy Markdown

Summary

Pilot migration of the users backend service away from Apache Thrift
toward 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/users

  • Deleted UserServlet.java — the Thrift TServlet that exposed
    UserHandler over binary Thrift protocol
  • Deleted WEB-INF/web.xml — the servlet mapping for the Thrift
    endpoint
  • Added UserRestController.java@RestController exposing all
    UserHandler methods as REST endpoints under /users/**
  • Added UserSpringApplication.java@SpringBootApplication
    entry point so the module runs as a standalone executable JAR
  • Added UserServiceConfig.java@Configuration that wires
    UserHandler as a Spring bean (constructor throws IOException,
    so direct @Service is not possible)
  • Added application.properties — sets server.port=8090,
    disables security auto-config for this internal service
  • Added DTOs: UserSearchRequest, UserExactSearchRequest,
    DeleteUserRequest, UpdateDepartmentRequest — clean request
    bodies replacing Thrift's multi-arg RPC calls
  • Modified UserHandler.java — removed implements UserService.Iface,
    removed all throws TException (replaced with throws SW360Exception
    where actually thrown, removed where not needed)
  • Modified pom.xml — changed packaging warjar, added
    spring-boot-starter-web and spring-boot-maven-plugin

libraries/datahandler

  • Added PagedUsersResult.java — DTO replacing the awkward
    Map<PaginationData, List<User>> Thrift return type with a flat
    JSON-serialisable structure

rest/resource-server

  • Modified Sw360UserService.java — replaced all ThriftClients /
    THttpClient calls with RestTemplate calls targeting the new
    Spring Boot users service (http://localhost:8090 by 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 as
Thrift-generated for now to keep this PR focused on the transport layer.
Full POJO migration is a follow-up.

Local testing

  • Ran docker compose up -d — all three services started successfully
    (sw360, couchdb, couchdb_nouveau)
  • Confirmed http://localhost:8080/users/ returns HTTP 200
  • Confirmed http://localhost:8080/health/ returns HTTP 200

Out of scope / follow-ups

  • Migrate remaining 21 backend services
  • Replace Thrift-generated POJOs with plain Java records
  • Migrate syncUser / synchronizeUserWithDatabase off ThriftClients
  • Consider gRPC as transport (noted in GSoC idea)

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
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