Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4411ba3
refactor: remove legacy cassandra-utils source files
chethann007 Jan 22, 2026
e64ee53
feat: add annotations for Cassandra clustering and partitioning keys
chethann007 Jan 22, 2026
f759620
feat: add Cassandra utility classes for configuration and database op…
chethann007 Jan 22, 2026
1657c65
feat: implement Cassandra connection manager and factory classes for …
chethann007 Jan 22, 2026
c980c03
feat: add Cassandra configuration and table column properties files
chethann007 Jan 22, 2026
1da9513
feat: add CassandraOperation interface and implementation
chethann007 Jan 22, 2026
4c2c50e
build: add POM file for sunbird-cassandra-utils with dependencies and…
chethann007 Jan 22, 2026
bbcb638
feat: add ProjectCommonException, ResponseCode, and ResponseMessage c…
chethann007 Jan 22, 2026
adcec4e
feat: add CustomLogFormat and LoggerUtil classes for enhanced logging…
chethann007 Jan 22, 2026
9aad9b0
build: add POM file for sunbird-platform-common with dependencies
chethann007 Jan 22, 2026
0716474
refactor: refactor logging imports from `org.sunbird.request.LoggerUt…
chethann007 Jan 22, 2026
dd041d3
refactor: remove LoggerUtil class to streamline logging functionality
chethann007 Jan 22, 2026
ed36f27
refactor: update LoggerUtil import paths and enhance request context …
chethann007 Jan 22, 2026
631eed7
build: update cassandra-utils dependency to sunbird-cassandra-utils
chethann007 Jan 22, 2026
bb5821b
refactor: update import paths for CassandraConnectionManager and Cass…
chethann007 Jan 22, 2026
47cbfb2
build: decouple sb-telemetry-utils and update deps
chethann007 Jan 22, 2026
b0f4049
build: decouple sb-common
chethann007 Jan 22, 2026
7b54f1d
build: update module structure and add cassandra-utils
chethann007 Jan 22, 2026
0ee0901
refactor: expand RequestContext with actor and logging metadata
chethann007 Jan 22, 2026
0f6cb3e
feat: add batchDelete and getUDTType operations
chethann007 Jan 22, 2026
30ecdf6
refactor: update template deletion to handle void return
chethann007 Jan 22, 2026
12c0e11
test: align actor tests with RequestContext and ServiceFactory updates
chethann007 Jan 22, 2026
c6c29f2
build: add sunbird-platform-common dependency to sb-utils
chethann007 Jan 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions all-actors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,19 @@
</dependency>
<dependency>
<groupId>org.sunbird</groupId>
<artifactId>cassandra-utils</artifactId>
<version>1.0.0</version>
<artifactId>sunbird-cassandra-utils</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.sunbird</groupId>
<artifactId>notification-sdk</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.sunbird</groupId>
<artifactId>sb-utils</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.everit.json</groupId>
<artifactId>org.everit.json.schema</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion all-actors/src/main/java/org/sunbird/BaseActor.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.sunbird.common.message.Localizer;
import org.sunbird.common.message.ResponseCode;
import org.sunbird.common.request.Request;
import org.sunbird.request.LoggerUtil;
import org.sunbird.logging.LoggerUtil;

import java.util.Locale;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.sunbird.common.message.IResponseMessage;
import org.sunbird.common.message.ResponseCode;
import org.sunbird.pojo.NotificationRequest;
import org.sunbird.request.LoggerUtil;
import org.sunbird.logging.LoggerUtil;

import java.text.MessageFormat;
import java.util.ArrayList;
Expand Down
29 changes: 21 additions & 8 deletions all-actors/src/main/java/org/sunbird/dao/NotificationDaoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
import org.sunbird.cassandra.CassandraOperation;
import org.sunbird.common.Constants;
import org.sunbird.common.exception.BaseException;
import org.sunbird.common.request.RequestContext;
import org.sunbird.common.response.Response;
import org.sunbird.notification.utils.Util;
import org.sunbird.pojo.NotificationFeed;
import org.sunbird.utils.ServiceFactory;
import org.sunbird.helper.ServiceFactory;

import java.util.*;

Expand Down Expand Up @@ -37,15 +38,15 @@ public static NotificationDao getInstance() {
public Response createNotificationFeed(List<NotificationFeed> feeds, Map<String,Object> reqContext) throws BaseException {
List<Map<String, Object>> feedList =
mapper.convertValue(feeds, new TypeReference<List<Map<String, Object>>>() {});
return cassandraOperation.batchInsert(KEY_SPACE_NAME, NOTIFICATION_FEED, feedList, reqContext);
return cassandraOperation.batchInsert(KEY_SPACE_NAME, NOTIFICATION_FEED, feedList, getRequestContext(reqContext));

}

@Override
public Response readNotificationFeed(String userId, Map<String,Object> reqContext) throws BaseException {
Map<String, Object> reqMap = new WeakHashMap<>(2);
reqMap.put(JsonKey.USER_ID, userId);
return cassandraOperation.getRecordById(KEY_SPACE_NAME,NOTIFICATION_FEED,reqMap,reqContext);
return cassandraOperation.getRecordById(KEY_SPACE_NAME,NOTIFICATION_FEED,reqMap,getRequestContext(reqContext));
}


Expand All @@ -68,7 +69,7 @@ public Response updateNotificationFeed( List<Map<String,Object>> feeds, Map<Stri
keysMap.put(Constants.NON_PRIMARY_KEY,nonPrimaryKeyMap);
properties.add(keysMap);
}
return cassandraOperation.batchUpdate(KEY_SPACE_NAME, NOTIFICATION_FEED, properties,reqContext);
return cassandraOperation.batchUpdate(KEY_SPACE_NAME, NOTIFICATION_FEED, properties,getRequestContext(reqContext));

}

Expand All @@ -86,18 +87,18 @@ public Response deleteUserFeed(List<NotificationFeed> feeds, Map<String,Object>
keysMap.put(Constants.NON_PRIMARY_KEY,nonPrimaryKeyMap);
properties.add(keysMap);
}
return cassandraOperation.batchUpdate(KEY_SPACE_NAME,NOTIFICATION_FEED, properties, context);
return cassandraOperation.batchUpdate(KEY_SPACE_NAME,NOTIFICATION_FEED, properties, getRequestContext(context));
}

@Override
public Response mapV1V2Feed(List<Map<String, Object>> mappedList, Map<String, Object> reqContext) {
return cassandraOperation.batchInsert(KEY_SPACE_NAME, FEED_VERSION_MAP, mappedList, reqContext);
return cassandraOperation.batchInsert(KEY_SPACE_NAME, FEED_VERSION_MAP, mappedList, getRequestContext(reqContext));

}

@Override
public Response getFeedMap(List<String> feedIds, Map<String, Object> reqContext) {
return cassandraOperation.getRecordsByPrimaryKeys(KEY_SPACE_NAME,FEED_VERSION_MAP,feedIds,JsonKey.ID,reqContext);
return cassandraOperation.getRecordsByPrimaryKeys(KEY_SPACE_NAME,FEED_VERSION_MAP,feedIds,JsonKey.ID,getRequestContext(reqContext));
}

@Override
Expand All @@ -109,6 +110,18 @@ public Response deleteUserFeedMap(List<String> feedIds, Map<String, Object> cont
map.put(JsonKey.STATUS,"deleted");
properties.add(map);
}
return cassandraOperation.batchUpdateById(KEY_SPACE_NAME,FEED_VERSION_MAP,properties,context);
return cassandraOperation.batchUpdateById(KEY_SPACE_NAME,FEED_VERSION_MAP,properties,getRequestContext(context));
}

private RequestContext getRequestContext(Map<String, Object> reqContext) {
RequestContext requestContext = new RequestContext();
if (reqContext != null) {
requestContext.setReqId((String) reqContext.get(JsonKey.REQUEST_ID));
requestContext.setActorId((String) reqContext.get(JsonKey.ACTOR_ID));
requestContext.setDid((String) reqContext.get(JsonKey.DEVICE_ID));
requestContext.setAppId((String) reqContext.get(JsonKey.APP_ID));
requestContext.getContextMap().putAll(reqContext);
}
return requestContext;
}
}
40 changes: 32 additions & 8 deletions all-actors/src/main/java/org/sunbird/dao/TemplateDaoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import org.sunbird.cassandra.CassandraOperation;
import org.sunbird.common.exception.BaseException;
import org.sunbird.common.request.RequestContext;
import org.sunbird.common.response.Response;
import org.sunbird.common.util.JsonKey;
import org.sunbird.pojo.ActionTemplate;
import org.sunbird.pojo.NotificationTemplate;
import org.sunbird.utils.ServiceFactory;
import org.sunbird.helper.ServiceFactory;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TemplateDaoImpl implements TemplateDao{
Expand All @@ -39,13 +44,13 @@ public Response createTemplate(NotificationTemplate template, Map<String, Object
Map<String, Object> map =
mapper.convertValue(template, new TypeReference<Map<String, Object>>() {});
map.put(JsonKey.CREATED_ON, new Timestamp(Calendar.getInstance().getTime().getTime()));
return cassandraOperation.insertRecord(KEY_SPACE_NAME, NOTIFICATION_TEMPLATE, map, reqContext);
return cassandraOperation.insertRecord(KEY_SPACE_NAME, NOTIFICATION_TEMPLATE, map, getRequestContext(reqContext));

}

@Override
public Response listTemplate(Map<String, Object> reqContext) throws BaseException {
return cassandraOperation.getAllRecords(KEY_SPACE_NAME,NOTIFICATION_TEMPLATE,reqContext);
return cassandraOperation.getAllRecords(KEY_SPACE_NAME,NOTIFICATION_TEMPLATE,getRequestContext(reqContext));
}

@Override
Expand All @@ -55,29 +60,48 @@ public Response updateTemplate(NotificationTemplate template, Map<String, Object
map.put(JsonKey.LAST_UPDATED_ON, new Timestamp(Calendar.getInstance().getTime().getTime()));
Map<String,Object> compositeKey = new HashMap<>();
compositeKey.put(JsonKey.TEMPLATE_ID,template.getTemplateId());
return cassandraOperation.updateRecord(KEY_SPACE_NAME, NOTIFICATION_TEMPLATE, map, compositeKey, reqContext);
return cassandraOperation.updateRecord(KEY_SPACE_NAME, NOTIFICATION_TEMPLATE, map, compositeKey, getRequestContext(reqContext));
}

@Override
public Response deleteTemplate(String templateId, Map<String, Object> reqContext) throws BaseException {
Map<String,String> compositeKey = new HashMap<>();
compositeKey.put(JsonKey.TEMPLATE_ID,templateId);
return cassandraOperation.deleteRecord(KEY_SPACE_NAME, NOTIFICATION_TEMPLATE, compositeKey, reqContext);
cassandraOperation.deleteRecord(KEY_SPACE_NAME, NOTIFICATION_TEMPLATE, compositeKey, getRequestContext(reqContext));
Response response = new Response();
response.put("response", "SUCCESS");
return response;
Comment on lines +70 to +73

Copilot AI Jan 28, 2026

Copy link

Choose a reason for hiding this comment

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

deleteTemplate constructs a new Response with hard-coded keys/values after calling deleteRecord(...). Prefer using existing constants (e.g., the shared response key and SUCCESS value) so callers see a consistent response shape across DAOs.

Suggested change
cassandraOperation.deleteRecord(KEY_SPACE_NAME, NOTIFICATION_TEMPLATE, compositeKey, getRequestContext(reqContext));
Response response = new Response();
response.put("response", "SUCCESS");
return response;
return cassandraOperation.deleteRecord(
KEY_SPACE_NAME,
NOTIFICATION_TEMPLATE,
compositeKey,
getRequestContext(reqContext));

Copilot uses AI. Check for mistakes.
}

@Override
public Response upsertActionTemplate(ActionTemplate actionTemplate, Map<String, Object> reqContext) throws BaseException {
Map<String, Object> map = mapper.convertValue(actionTemplate, Map.class);
return cassandraOperation.upsertRecord(KEY_SPACE_NAME,ACTION_TEMPLATE,map,reqContext);
return cassandraOperation.upsertRecord(KEY_SPACE_NAME,ACTION_TEMPLATE,map,getRequestContext(reqContext));
}

@Override
public Response getTemplate(String templateId, Map<String,Object> reqContext) throws BaseException {
return cassandraOperation.getRecordsByProperty(KEY_SPACE_NAME,NOTIFICATION_TEMPLATE, org.sunbird.JsonKey.TEMPLATE_ID,templateId,reqContext);
List<Object> values = new ArrayList<>();
values.add(templateId);
return cassandraOperation.getRecordsByProperty(KEY_SPACE_NAME,NOTIFICATION_TEMPLATE, org.sunbird.JsonKey.TEMPLATE_ID,values,getRequestContext(reqContext));

}
@Override
public Response getTemplateId(String actionType, Map<String,Object> reqContext) throws BaseException {
return cassandraOperation.getRecordsByProperty(KEY_SPACE_NAME,ACTION_TEMPLATE, org.sunbird.JsonKey.ACTION,actionType,reqContext);
List<Object> values = new ArrayList<>();
values.add(actionType);
return cassandraOperation.getRecordsByProperty(KEY_SPACE_NAME,ACTION_TEMPLATE, org.sunbird.JsonKey.ACTION,values,getRequestContext(reqContext));
}

private RequestContext getRequestContext(Map<String, Object> reqContext) {
RequestContext requestContext = new RequestContext();
if (reqContext != null) {
requestContext.setReqId((String) reqContext.get(JsonKey.REQUEST_ID));
requestContext.setActorId((String) reqContext.get(JsonKey.ACTOR_ID));
requestContext.setDid((String) reqContext.get(JsonKey.DEVICE_ID));
requestContext.setAppId((String) reqContext.get(JsonKey.APP_ID));
requestContext.getContextMap().putAll(reqContext);
}
return requestContext;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.sunbird.notification.handler.INotificationHandler;
import org.sunbird.notification.handler.NotificationHandlerFactory;
import org.sunbird.pojo.NotificationV2Request;
import org.sunbird.request.LoggerUtil;
import org.sunbird.logging.LoggerUtil;
import org.sunbird.telemetry.TelemetryEnvKey;
import org.sunbird.telemetry.util.TelemetryUtil;
import org.sunbird.util.Util;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.sunbird.common.message.ResponseCode;
import org.sunbird.common.request.Request;
import org.sunbird.common.response.Response;
import org.sunbird.request.LoggerUtil;
import org.sunbird.logging.LoggerUtil;
import org.sunbird.service.NotificationService;
import org.sunbird.service.NotificationServiceImpl;
import org.sunbird.util.RequestHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.sunbird.notification.dispatcher.NotificationRouter;
import org.sunbird.notification.utils.NotificationConstant;
import org.sunbird.pojo.NotificationRequest;
import org.sunbird.request.LoggerUtil;
import org.sunbird.logging.LoggerUtil;
import org.sunbird.util.validator.OtpRequestValidator;

import com.fasterxml.jackson.core.type.TypeReference;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.sunbird.common.response.Response;
import org.sunbird.pojo.ActionTemplate;
import org.sunbird.pojo.NotificationTemplate;
import org.sunbird.request.LoggerUtil;
import org.sunbird.logging.LoggerUtil;
import org.sunbird.service.TemplateService;
import org.sunbird.service.TemplateServiceImpl;
import org.sunbird.util.RequestHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.sunbird.common.message.ResponseCode;
import org.sunbird.common.request.Request;
import org.sunbird.common.response.Response;
import org.sunbird.request.LoggerUtil;
import org.sunbird.logging.LoggerUtil;
import org.sunbird.service.NotificationService;
import org.sunbird.service.NotificationServiceImpl;
import org.sunbird.util.RequestHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.sunbird.common.message.ResponseCode;
import org.sunbird.common.request.Request;
import org.sunbird.common.response.Response;
import org.sunbird.request.LoggerUtil;
import org.sunbird.logging.LoggerUtil;
import org.sunbird.service.NotificationService;
import org.sunbird.service.NotificationServiceImpl;
import org.sunbird.util.RequestHandler;
Expand All @@ -33,7 +33,7 @@ public class UpdateNotificationActor extends BaseActor {
private static LoggerUtil logger = new LoggerUtil(UpdateNotificationActor.class);

@Override
public void onReceive(Request request) throws Throwable {
public void onReceive(Request request) throws Throwable {
String operation = request.getOperation();
switch (operation) {
case "updateFeed":
Expand All @@ -46,20 +46,20 @@ public void onReceive(Request request) throws Throwable {
}
}
private void updateV1Feed(Request request){
logger.info(request.getContext(),"UpdateNotificationActor: updateV1Feed Started");
logger.info(request.getRequestContext(),"UpdateNotificationActor: updateV1Feed Started");

String requestedBy = (String) request.getRequest().get(JsonKey.USER_ID);
updateFeed(request,requestedBy);
logger.info(request.getContext(),"UpdateNotificationActor: updateV1Feed Ended");
logger.info(request.getRequestContext(),"UpdateNotificationActor: updateV1Feed Ended");

}

private void updateV2Feed(Request request){
logger.info(request.getContext(),"UpdateNotificationActor: updateV2Feed Started");
logger.info(request.getRequestContext(),"UpdateNotificationActor: updateV2Feed Started");
RequestHandler requestHandler = new RequestHandler();
String requestedBy = requestHandler.getRequestedBy(request);
updateFeed(request,requestedBy);
logger.info(request.getContext(),"UpdateNotificationActor: updateV2Feed Ended");
logger.info(request.getRequestContext(),"UpdateNotificationActor: updateV2Feed Ended");

}

Expand Down Expand Up @@ -105,14 +105,14 @@ private void updateFeed(Request request, String requestedBy){
sender().tell(response, getSelf());

} catch (BaseException ex){
logger.error(request.getContext(),MessageFormat.format(":Error Msg: {0} ",ex.getMessage()),
logger.error(request.getRequestContext(),MessageFormat.format(":Error Msg: {0} ",ex.getMessage()),
ex);
throw ex;
}
catch (Exception ex){
logger.error(request.getContext(),MessageFormat.format("UpdateNotificationActor:Error Msg: {0} ",ex.getMessage()),
logger.error(request.getRequestContext(),MessageFormat.format("UpdateNotificationActor:Error Msg: {0} ",ex.getMessage()),
ex);
throw new BaseException(IResponseMessage.Key.SERVER_ERROR,IResponseMessage.Message.INTERNAL_ERROR, ResponseCode.serverError.getResponseCode());
throw new BaseException(IResponseMessage.Key.SERVER_ERROR,IResponseMessage.Message.INTERNAL_ERROR, ResponseCode.serverError.getResponseCode());
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.sunbird.pojo.Config;
import org.sunbird.pojo.NotificationRequest;
import org.sunbird.pojo.OTP;
import org.sunbird.request.LoggerUtil;
import org.sunbird.logging.LoggerUtil;
import org.sunbird.util.Constant;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.sunbird.pojo.EventData;
import org.sunbird.pojo.KafkaMessage;
import org.sunbird.pojo.NotificationRequest;
import org.sunbird.request.LoggerUtil;
import org.sunbird.logging.LoggerUtil;
import org.sunbird.util.ConfigUtil;
import org.sunbird.util.Constant;
import org.sunbird.util.DataHash;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.sunbird.pojo.Config;
import org.sunbird.pojo.NotificationRequest;
import org.sunbird.pojo.NotificationV2Request;
import org.sunbird.request.LoggerUtil;
import org.sunbird.logging.LoggerUtil;
import org.sunbird.util.Util;

import java.text.MessageFormat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.sunbird.pojo.NotificationRequest;
import org.sunbird.pojo.NotificationV2Request;
import org.sunbird.pojo.Template;
import org.sunbird.request.LoggerUtil;
import org.sunbird.logging.LoggerUtil;
import org.sunbird.service.NotificationService;
import org.sunbird.service.NotificationServiceImpl;
import org.sunbird.util.Util;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.sunbird.pojo.NotificationFeed;
import org.sunbird.pojo.NotificationType;
import org.sunbird.pojo.NotificationV2Request;
import org.sunbird.request.LoggerUtil;
import org.sunbird.logging.LoggerUtil;
import org.sunbird.service.NotificationService;
import org.sunbird.service.NotificationServiceImpl;
import org.sunbird.util.Util;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.sunbird.notification.dispatcher.SyncMessageDispatcher;
import org.sunbird.notification.utils.NotificationConstant;
import org.sunbird.pojo.*;
import org.sunbird.request.LoggerUtil;
import org.sunbird.logging.LoggerUtil;
import org.sunbird.service.NotificationService;
import org.sunbird.service.NotificationServiceImpl;
import org.sunbird.util.Util;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.sunbird.dao.TemplateDao;
import org.sunbird.dao.TemplateDaoImpl;
import org.sunbird.pojo.NotificationFeed;
import org.sunbird.request.LoggerUtil;
import org.sunbird.logging.LoggerUtil;

import java.io.IOException;
import java.io.StringWriter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.sunbird.dao.TemplateDaoImpl;
import org.sunbird.pojo.ActionTemplate;
import org.sunbird.pojo.NotificationTemplate;
import org.sunbird.request.LoggerUtil;
import org.sunbird.logging.LoggerUtil;

import java.text.MessageFormat;
import java.util.ArrayList;
Expand Down
Loading
Loading