Source:
<code>public synchronized void onWorkspaceChatSettingsEnabledEvent (@Observes WorkspaceChatSettingsEnabledEvent event) { String workspaceIdentifier = event.getWorkspaceIdentifier(); String workspaceDataSource = event.getWorkspaceDataSource(); WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceByDataSourceAndIdentifier(workspaceDataSource, workspaceIdentifier); List<WorkspaceUserEntity> activeWorkspaceStudents = workspaceUserEntityController.listActiveWorkspaceStudents(workspaceEntity); List<WorkspaceUserEntity> workspaceStaffMembers = workspaceUserEntityController.listActiveWorkspaceStaffMembers(workspaceEntity); for (WorkspaceUserEntity activeWorkspaceStudent : activeWorkspaceStudents) { SchoolDataIdentifier user = new SchoolDataIdentifier(activeWorkspaceStudent.getUserSchoolDataIdentifier().getIdentifier(), activeWorkspaceStudent.getUserSchoolDataIdentifier().getDataSource().getIdentifier()); UserChatSettings userChatSetting = chatController.findUserChatSettings(user); if (userChatSetting != null && userChatSetting.getVisibility().toString() == "VISIBLE_TO_ALL"){ <START> chatSyncController.syncStudent(user); <END> } } for (WorkspaceUserEntity workspaceStaffMember : workspaceStaffMembers) { SchoolDataIdentifier user = new SchoolDataIdentifier(workspaceStaffMember.getUserSchoolDataIdentifier().getIdentifier(), workspaceStaffMember.getUserSchoolDataIdentifier().getDataSource().getIdentifier()); UserChatSettings userChatSetting = chatController.findUserChatSettings(user); if (userChatSetting != null && userChatSetting.getVisibility().toString() == "VISIBLE_TO_ALL"){ chatSyncController.syncStudent(user); } } }</code><technical_language>above, syncing user-workspace combination more efficient</technical_language>

Target:
public synchronized void onWorkspaceChatSettingsEnabledEvent (@Observes WorkspaceChatSettingsEnabledEvent event) { String workspaceIdentifier = event.getWorkspaceIdentifier(); String workspaceDataSource = event.getWorkspaceDataSource(); WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceByDataSourceAndIdentifier(workspaceDataSource, workspaceIdentifier); List<WorkspaceUserEntity> activeWorkspaceStudents = workspaceUserEntityController.listActiveWorkspaceStudents(workspaceEntity); List<WorkspaceUserEntity> workspaceStaffMembers = workspaceUserEntityController.listActiveWorkspaceStaffMembers(workspaceEntity); for (WorkspaceUserEntity activeWorkspaceStudent : activeWorkspaceStudents) { SchoolDataIdentifier user = new SchoolDataIdentifier(activeWorkspaceStudent.getUserSchoolDataIdentifier().getIdentifier(), activeWorkspaceStudent.getUserSchoolDataIdentifier().getDataSource().getIdentifier()); UserChatSettings userChatSetting = chatController.findUserChatSettings(user); if (userChatSetting != null && UserChatVisibility.VISIBLE_TO_ALL.equals(userChatSetting.getVisibility())){ chatSyncController.syncWorkspaceUser(workspaceEntity, user); } } for (WorkspaceUserEntity workspaceStaffMember : workspaceStaffMembers) { SchoolDataIdentifier user = new SchoolDataIdentifier(workspaceStaffMember.getUserSchoolDataIdentifier().getIdentifier(), workspaceStaffMember.getUserSchoolDataIdentifier().getDataSource().getIdentifier()); UserChatSettings userChatSetting = chatController.findUserChatSettings(user); if (userChatSetting != null && UserChatVisibility.VISIBLE_TO_ALL.equals(userChatSetting.getVisibility())){ chatSyncController.syncWorkspaceUser(workspaceEntity, user); } } }