Skip to content

Unified Sunbird Platform Common Module - #645

Closed
chethann007 wants to merge 26 commits into
developfrom
platform_common
Closed

Unified Sunbird Platform Common Module#645
chethann007 wants to merge 26 commits into
developfrom
platform_common

Conversation

@chethann007

Copy link
Copy Markdown
Contributor

Summary

Integrated and consolidated the legacy common-utilities and related utility modules into a single, unified core/sunbird-platform-common module. 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

  • New Core Module: Established core/sunbird-platform-common as the unified base library, consolidating logic from multiple legacy utility modules.
  • Legacy Cleanup: Removed the redundant common-utils and core/sunbird-event-utils modules to eliminate technical debt and version fragmentation.
  • Global Refactoring: Updated the entire codebase across course-mw, service, and core sub-modules to reference the new unified library, standardizing imports and dependency management.
  • Improved Standardization: Unified the logging patterns, telemetry generation, and error handling codes into a single shared interface.

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.

…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

Use a secure padding scheme. See more on SonarQube Cloud
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

Use a secure padding scheme. See more on SonarQube Cloud

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-common module consolidating logic from multiple legacy utility modules
  • Removed redundant common-utils and core/sunbird-event-utils modules
  • 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,

Copilot AI Feb 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
ResponseCode.userNotAssociatedToRootOrg,
ResponseCode.userNotAssociatedToRootOrg.getErrorCode(),

Copilot uses AI. Check for mistakes.
@@ -70,7 +70,7 @@ public void validateBulkUploadFields(
}
if (!(ArrayUtils.contains(csvHeaderLine, x))) {
throw new ProjectCommonException(
ResponseCode.mandatoryParamsMissing.getErrorCode(),
ResponseCode.mandatoryParamsMissing,

Copilot AI Feb 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
ResponseCode.mandatoryParamsMissing,
ResponseCode.mandatoryParamsMissing.getErrorCode(),

Copilot uses AI. Check for mistakes.
@@ -91,7 +91,7 @@ public void validateBulkUploadFields(

private void throwInvalidColumnException(String invalidColumn, String validColumns) {
throw new ProjectCommonException(
ResponseCode.invalidColumns.getErrorCode(),
ResponseCode.invalidColumns,

Copilot AI Feb 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +26
// private static final CassandraPropertyReader propertiesCache =
// CassandraPropertyReader.getInstance();

Copilot AI Feb 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// private static final CassandraPropertyReader propertiesCache =
// CassandraPropertyReader.getInstance();

Copilot uses AI. Check for mistakes.
cell.setCellValue((Double) obj);
} else {
if (ProjectUtil.isNotNull(obj)) {
if (null != (obj)) {

Copilot AI Feb 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
if (null != (obj)) {
if (null != obj) {

Copilot uses AI. Check for mistakes.
Comment on lines +120 to +126
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);
}

Copilot AI Feb 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
…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.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
4 Security Hotspots
7.3% Duplication on New Code (required ≤ 3%)
E Reliability Rating on New Code (required ≥ A)
D Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
10 Security Hotspots
9.8% Coverage on New Code (required ≥ 80%)
4.3% Duplication on New Code (required ≤ 3%)
E Reliability Rating on New Code (required ≥ A)
D Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

3 participants