Skip to content

refactor(duplicate-code): Unify Attrs constants, add ResponseBuilder to core#11

Open
maheshkumargangula wants to merge 2 commits intodevelopfrom
refactor/duplicate-code
Open

refactor(duplicate-code): Unify Attrs constants, add ResponseBuilder to core#11
maheshkumargangula wants to merge 2 commits intodevelopfrom
refactor/duplicate-code

Conversation

@maheshkumargangula
Copy link

PR Title

refactor(duplicate-code): Unify Attrs constants, add ResponseBuilder, consolidate core utilities

Base Branch

develop

Summary

  • Unified Attrs.java: The three separate Attrs.java files (UserOrg, LMS, Notification) had overlapping request attribute keys with naming inconsistencies (USER_ID vs USERID). Created a canonical org.sunbird.request.Attrs in sunbird-platform-common. Service-level files now reference or deprecate in favour of the core version.
  • New ResponseBuilder: Fluent builder API to replace the new Response() + setVer() + setId() + setTs() + setParams() pattern found 419+ times. Provides ResponseBuilder.ok(), ResponseBuilder.error(), and ResponseBuilder.create() factory methods.
  • Updated BaseController: Updated UserOrg BaseController to use the new ResponseBuilder pattern as a reference implementation.

Files Changed

  • core/sunbird-platform-common/.../request/Attrs.java (new — canonical definition)
  • core/sunbird-platform-common/.../response/ResponseBuilder.java (new)
  • modules/lms/service/app/util/Attrs.java (added @deprecated + pointer to core)
  • modules/notification/service/app/utils/module/Attrs.java (added @deprecated + pointer to core)
  • modules/userorg/controller/app/util/Attrs.java (added @deprecated + pointer to core)
  • modules/userorg/controller/app/controllers/BaseController.java (updated to use ResponseBuilder)

Implements Tasks

DC-02, DC-05

Test Plan

  • Build all services: mvn clean install -P lern -DskipTests
  • No import errors — all Attrs usages resolve correctly
  • Verify ResponseBuilder produces identical JSON output to the manual approach

Claude Coordinator and others added 2 commits February 21, 2026 17:10
… consolidate

- Create unified Attrs.java in sunbird-platform-common with all service request attribute constants (DC-02)
- Add deprecation notices to service-level Attrs.java files pointing to core location (DC-02)
- Create ResponseBuilder fluent API to replace new Response() boilerplate (DC-05)
- Update BaseController to use ResponseBuilder pattern (DC-05)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…s import

- Convert modules/userorg/controller/app/util/Attrs.java to deprecation shim
  (matching LMS and Notification Attrs pattern already in this branch)
- Add explicit ResponseParams import to ResponseBuilder.java for code clarity

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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