Source:
protected void updateInstructorWithSectionLevelPrivileges(String courseId, InstructorAttributes instructor) { List<String> sectionNames = null; try { sectionNames = logic.getSectionNamesForCourse(courseId); } catch (EntityDoesNotExistException e) { return; } HashMap<String, Boolean> isSectionSpecialMappings = new HashMap<>(); for (String sectionName : sectionNames) { isSectionSpecialMappings.put(sectionName, false); } List<String> feedbackNames = new ArrayList<>(); List<FeedbackSessionAttributes> feedbacks = logic.getFeedbackSessionsForCourse(courseId); for (FeedbackSessionAttributes feedback : feedbacks) { feedbackNames.add(feedback.getFeedbackSessionName()); } Map<String, List<String>> sectionNamesMap = getSectionsWithSpecialPrivilegesFromParameters( instructor, sectionNames, isSectionSpecialMappings); sectionNamesMap.forEach((sectionGroupName, specialSectionsInSectionGroup) -> { updateInstructorPrivilegesForSectionInSectionLevel(sectionGroupName, specialSectionsInSectionGroup, instructor); String setSessionsStr = getRequestParamValue("is" + sectionGroupName + "sessionsset"); boolean isSessionsForSectionGroupSpecial = Boolean.parseBoolean(setSessionsStr); if (isSessionsForSectionGroupSpecial) { updateInstructorPrivilegesForSectionInSessionLevel(sectionGroupName, specialSectionsInSectionGroup, feedbackNames, instructor); } else { removeSessionLevelPrivileges(instructor, specialSectionsInSectionGroup); } }); isSectionSpecialMappings.forEach((sectionNameToBeChecked, value) -> { boolean isSectionSpecial = value.booleanValue(); if (!isSectionSpecial) { instructor.privileges.removeSectionLevelPrivileges(sectionNameToBeChecked); } }); }

Target:
protected void updateInstructorWithSectionLevelPrivileges(String courseId, InstructorAttributes instructor) { List<String> sectionNames = null; try { sectionNames = logic.getSectionNamesForCourse(courseId); } catch (EntityDoesNotExistException e) { return; } HashMap<String, Boolean> isSectionSpecialMappings = new HashMap<>(); for (String sectionName : sectionNames) { isSectionSpecialMappings.put(sectionName, false); } List<String> feedbackNames = new ArrayList<>(); List<FeedbackSessionAttributes> feedbacks = logic.getFeedbackSessionsForCourse(courseId); for (FeedbackSessionAttributes feedback : feedbacks) { feedbackNames.add(feedback.getFeedbackSessionName()); } Map<String, List<String>> sectionNamesMap = getSectionsWithSpecialPrivilegesFromParameters( instructor, sectionNames, isSectionSpecialMappings); sectionNamesMap.forEach((sectionGroupName, specialSectionsInSectionGroup) -> { updateInstructorPrivilegesForSectionInSectionLevel(sectionGroupName, specialSectionsInSectionGroup, instructor); String setSessionsStr = getRequestParamValue("is" + sectionGroupName + "sessionsset"); boolean isSessionsForSectionGroupSpecial = Boolean.parseBoolean(setSessionsStr); if (isSessionsForSectionGroupSpecial) { updateInstructorPrivilegesForSectionInSessionLevel(sectionGroupName, specialSectionsInSectionGroup, feedbackNames, instructor); } else { removeSessionLevelPrivileges(instructor, specialSectionsInSectionGroup); } }); isSectionSpecialMappings.forEach((sectionNameToBeChecked, isSectionSpecial) -> { if (!isSectionSpecial) { instructor.privileges.removeSectionLevelPrivileges(sectionNameToBeChecked); } }); }