Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #LR-676 feat: Delete User API #1234

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class InstructionEventGenerator {
private static String beJobRequesteventId = "BE_JOB_REQUEST";
private static int iteration = 1;

private static String actorId = "Sunbird LMS Samza Job";
private static String actorId = "Sunbird LMS Flink Job";
private static String actorType = "System";
private static String pdataId = "org.sunbird.platform";
private static String pdataVersion = "1.0";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ public final class JsonKey {
public static final String SUGGESTED_USERS = "suggested_users";
public static final String DELETE_USER_ACTON = "delete-user";
public static final String OBJECT = "object";
public static final String EDATA = "eData";
public static final String EDATA = "edata";
public static final String MANAGED_USERS = "managed_users";
public static final String USER_DELETION_TOPIC = "user-deletion-broadcast-topic";
public static final String USER_DELETION_ROLES = "user-deletion-roles";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,35 @@ private void inputKafkaTopic(Request request) throws Exception {
Map<String, Object> searchFilter = new HashMap<>();
searchFilter.put(JsonKey.ROOT_ORG_ID, rootOrgId);

if (!roles.isEmpty()) {
// for each role in the organisation, fetch list of other users to pass it as part of event
List<String> queryFields = new ArrayList<>();
queryFields.add(JsonKey.USER_ID);
searchQueryMap.put(JsonKey.FIELDS, queryFields);
logger.info("UserDeletionBackgroundJobActor::inputKafkaTopic:: roles size:: " + roles.size());
roles.forEach(
role -> {
searchFilter.put(JsonKey.ROLES + "." + JsonKey.ROLE, role);
searchQueryMap.put(JsonKey.FILTERS, searchFilter);
SearchDTO searchDto = ElasticSearchHelper.createSearchDTO(searchQueryMap);
Map<String, Object> result =
userService.searchUser(searchDto, request.getRequestContext());
List<Map<String, Object>> userMapList =
(List<Map<String, Object>>) result.get(JsonKey.CONTENT);

if (!userMapList.isEmpty()) {
Map<String, Object> roleUsersMap = new HashMap<>();
roleUsersMap.put(JsonKey.ROLE, role);
List<String> roleUsersList = new ArrayList<>();
for (Map<String, Object> userMap : userMapList) {
roleUsersList.add((String) userMap.get(JsonKey.USER_ID));
}
roleUsersMap.put(JsonKey.USERS, roleUsersList);
suggestedUsersList.add(roleUsersMap);
if (!roles.contains(JsonKey.ORG_ADMIN)) roles.add(JsonKey.ORG_ADMIN);

// for each role in the organisation, fetch list of other users to pass it as part of event
List<String> queryFields = new ArrayList<>();
queryFields.add(JsonKey.USER_ID);
searchQueryMap.put(JsonKey.FIELDS, queryFields);
logger.info("UserDeletionBackgroundJobActor::inputKafkaTopic:: roles size:: " + roles.size());
roles.forEach(
role -> {
searchFilter.put(JsonKey.ROLES + "." + JsonKey.ROLE, role);
searchQueryMap.put(JsonKey.FILTERS, searchFilter);
SearchDTO searchDto = ElasticSearchHelper.createSearchDTO(searchQueryMap);
Map<String, Object> result =
userService.searchUser(searchDto, request.getRequestContext());
List<Map<String, Object>> userMapList =
(List<Map<String, Object>>) result.get(JsonKey.CONTENT);

if (!userMapList.isEmpty()) {
Map<String, Object> roleUsersMap = new HashMap<>();
roleUsersMap.put(JsonKey.ROLE, role);
List<String> roleUsersList = new ArrayList<>();
for (Map<String, Object> userMap : userMapList) {
roleUsersList.add((String) userMap.get(JsonKey.USER_ID));
}
});
}
roleUsersMap.put(JsonKey.USERS, roleUsersList);
suggestedUsersList.add(roleUsersMap);
}
});

logger.info(
"UserDeletionBackgroundJobActor::inputKafkaTopic:: suggestedUsersList size:: "
+ suggestedUsersList.size());
Expand Down