Unified Sunbird Platform Common Module - #645
Conversation
…tils` module and update references.
…utils - Migrate InstructionEventGenerator and KafkaClient from common-util to core module. - Rewrite implementation to improve code quality and provide generalized support for all Lern microservices. - Update package naming to org.sunbird.kafka for better modularity. - Revise sunbird-event-utils pom.xml to include sunbird-platform-common and required kafka-clients. - Remove legacy and redundant kafka client implementations from common-util.
- Delete redundant utility classes, exception handlers, and security services from sunbird-platform-core/common-util. - Remove legacy auth-verifier module to prepare for migration to core/sunbird-platform-common. - Cleanup unused test suites and resource files across the platform-core modules.
- Add shared utilities for auth, security, logging, and HTTP. - Implement core request, response, and exception models. - Centralize common resource templates and configurations.
- Register sunbird-platform-common module. - Add and update dependency versions for Kafka, Apache Pekko, Keycloak, Apache Commons, and Cloud Storage SDK.
- Update pom.xml to use sunbird-platform-common instead of sunbird-commons. - Refactor imports across Cassandra utility classes to use new packages - Add Netty exclusions in pom.xml to resolve dependency conflicts.
- Update pom.xml to use sunbird-platform-common as the core dependency. - Refactor imports in ES utility classes to use new common packages.
…orm-common - Update pom.xml to depend on sunbird-platform-common. - Refactor package imports in common actors, DAOs, and utility classes to align with the new core structure. - Update corresponding unit tests to reflect package restructuring.
- Update enrolment-actor pom.xml to use sunbird-platform-common. - Refactor package imports in Scala actors (BaseEnrolmentActor, CourseEnrolmentActor, etc.) to point to new common packages. - Update Scala-based unit tests to align with the package restructuring.
- Unregister common-util and auth-verifier modules from the sunbird-platform-core parent POM following their migration to core/sunbird-platform-common.
- Update pom.xml to use sunbird-platform-common instead of common-util. - Refactor base actor classes and routers to use updated package imports.
- Update pom.xml to use sunbird-platform-common as the core utility dependency. - Refactor client implementations (User, Org, Location, Email, CourseEnrollment) to use new package imports.
- Refactor all controllers, filters, and request mappers to use the new org.sunbird.* package structure for request, response, and exceptions. - Update application.conf to reflect package changes in Pekko serialization bindings for Request and Response classes. - Update utility classes (RequestInterceptor, AuthenticationHelper) and service modules (ErrorHandler, ApplicationStart) to align with the core module. - Refactor comprehensive test suites across controllers and utilities to ensure compatibility with the platform-common library.
…teasy, add Play/Scala versions, and introduce the `SUNBIRD_VALID_LOCATION_TYPES` constant.
| try { | ||
| sunbird_encryption = DefaultEncryptionServiceImpl.getSalt(); | ||
| Key key = generateKey(); | ||
| c = Cipher.getInstance(ALGORITHM); |
Check failure
Code scanning / SonarCloud
Encryption algorithms should be used with secure mode and padding scheme High
| try { | ||
| encryption_key = getSalt(); | ||
| Key key = generateKey(); | ||
| c = Cipher.getInstance(ALGORITHM); |
Check failure
Code scanning / SonarCloud
Encryption algorithms should be used with secure mode and padding scheme High
There was a problem hiding this comment.
Pull request overview
This PR consolidates legacy utility modules into a unified core/sunbird-platform-common module, establishing it as the centralized source for base classes, utilities, logging, telemetry, and shared configurations across all Lern microservices.
Changes:
- Created unified
core/sunbird-platform-commonmodule consolidating logic from multiple legacy utility modules - Removed redundant
common-utilsandcore/sunbird-event-utilsmodules - Refactored entire codebase to reference the new unified library with standardized imports and dependency management
Reviewed changes
Copilot reviewed 163 out of 447 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| course-mw/course-actors/src/main/java/org/sunbird/learner/actors/coursebatch/CourseBatchManagementActor.java | Updated imports and method signatures to align with new unified module |
| course-mw/course-actors-common/src/main/java/org/sunbird/learner/actors/coursebatch/dao/impl/CourseBatchDaoImpl.java | Commented out CassandraPropertyReader reference |
| course-mw/course-actors-common/pom.xml | Added dependency on new sunbird-platform-common module |
| core/sunbird-platform-common/src/main/java/org/sunbird/validators/PhoneValidator.java | Moved and updated phone validation utility with enhanced documentation |
| core/sunbird-platform-common/src/main/java/org/sunbird/utils/JsonUtil.java | New centralized JSON utility with serialization/deserialization methods |
| core/sunbird-platform-common/src/main/java/org/sunbird/telemetry/util/TelemetryWriter.java | Consolidated telemetry writing logic with improved error handling |
| core/sunbird-platform-common/src/main/java/org/sunbird/response/ResponseCode.java | Core response code definitions (referenced in context) |
| core/sunbird-es-utils/src/main/java/org/sunbird/common/inf/ElasticSearchService.java | Interface for ES operations with reordered parameters |
| core/sunbird-cassandra-utils/src/main/java/org/sunbird/cassandraimpl/CassandraOperationImpl.java | Updated imports to reference new common module |
| core/pom.xml | Added build configuration and dependency version properties |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -296,7 +299,7 @@ private void validateMentors(CourseBatch courseBatch, String authToken, RequestC | |||
| String mentorRootOrgId = getRootOrgFromUserMap(result); | |||
| if (StringUtils.isEmpty(batchCreatorRootOrgId) || !batchCreatorRootOrgId.equals(mentorRootOrgId)) { | |||
| throw new ProjectCommonException( | |||
| ResponseCode.userNotAssociatedToRootOrg.getErrorCode(), | |||
| ResponseCode.userNotAssociatedToRootOrg, | |||
There was a problem hiding this comment.
The ProjectCommonException constructor is being called with a ResponseCode enum instead of an error code string. Verify that the ProjectCommonException constructor has been updated to accept ResponseCode directly, or call .getErrorCode() on the enum to maintain backward compatibility.
| ResponseCode.userNotAssociatedToRootOrg, | |
| ResponseCode.userNotAssociatedToRootOrg.getErrorCode(), |
| @@ -70,7 +70,7 @@ public void validateBulkUploadFields( | |||
| } | |||
| if (!(ArrayUtils.contains(csvHeaderLine, x))) { | |||
| throw new ProjectCommonException( | |||
| ResponseCode.mandatoryParamsMissing.getErrorCode(), | |||
| ResponseCode.mandatoryParamsMissing, | |||
There was a problem hiding this comment.
Multiple ProjectCommonException calls are passing ResponseCode enums directly instead of error code strings. Ensure the exception constructor signature has been updated to accept ResponseCode enums, or use .getErrorCode() method to extract the string value.
| ResponseCode.mandatoryParamsMissing, | |
| ResponseCode.mandatoryParamsMissing.getErrorCode(), |
| @@ -91,7 +91,7 @@ public void validateBulkUploadFields( | |||
|
|
|||
| private void throwInvalidColumnException(String invalidColumn, String validColumns) { | |||
| throw new ProjectCommonException( | |||
| ResponseCode.invalidColumns.getErrorCode(), | |||
| ResponseCode.invalidColumns, | |||
There was a problem hiding this comment.
Multiple ProjectCommonException calls are passing ResponseCode enums directly instead of error code strings. Ensure the exception constructor signature has been updated to accept ResponseCode enums, or use .getErrorCode() method to extract the string value.
| // private static final CassandraPropertyReader propertiesCache = | ||
| // CassandraPropertyReader.getInstance(); |
There was a problem hiding this comment.
Commented-out code should be removed rather than left in place. If CassandraPropertyReader is no longer needed, delete these lines. If it's needed, uncomment and ensure it's properly imported and used.
| // private static final CassandraPropertyReader propertiesCache = | |
| // CassandraPropertyReader.getInstance(); |
| cell.setCellValue((Double) obj); | ||
| } else { | ||
| if (ProjectUtil.isNotNull(obj)) { | ||
| if (null != (obj)) { |
There was a problem hiding this comment.
Unnecessary parentheses around obj. The null check should be simplified to if (obj != null) or if (null != obj) for consistency with the rest of the codebase.
| if (null != (obj)) { | |
| if (null != obj) { |
| Map<String, Object> props = (Map<String, Object>) params.get(JsonKey.PROPS); | ||
|
|
||
| // Check for type in props and add to params if present | ||
| if (props != null && props.containsKey(JsonKey.TYPE)) { | ||
| String type = (String) props.get(JsonKey.TYPE); | ||
| params.put(JsonKey.TYPE, type); | ||
| } |
There was a problem hiding this comment.
This logic extracts type from nested props and adds it directly to params. Consider documenting why this transformation is necessary, as it modifies the input params map and may have side effects on the caller.
…nt-actor - Update imports for JsonKey, LoggerUtil, ProjectUtil, PropertiesCache, and response/request classes to their new locations. - Fix LoggerUtil.warn signature mismatches in AssessmentAggregatorActor to include needed Throwable argument. - Correct KafkaClient import path in Kafka Service and Wrapper. - Resolve test compilation failures in assessment-aggregator by updating import paths in Spec files.
…sessmentAggregatorActor`.
|
|




Summary
Integrated and consolidated the legacy common-utilities and related utility modules into a single, unified
core/sunbird-platform-commonmodule. This module now serves as the centralized source of truth for base classes, common utilities, logging, telemetry, and shared configurations across all Lern microservices.Key Changes
core/sunbird-platform-commonas the unified base library, consolidating logic from multiple legacy utility modules.common-utilsandcore/sunbird-event-utilsmodules to eliminate technical debt and version fragmentation.course-mw,service, andcoresub-modules to reference the new unified library, standardizing imports and dependency management.Impact
Provides a consistent and robust foundation for all Lern microservices, reduces footprint by eliminating duplicate libraries, simplifies dependency management, and ensures that improvements to core utilities are universally applied across the platform.