Source:
public List<String> synchronizeGroupStructure(PerunSession sess, Group baseGroup) throws InternalErrorException, AttributeNotExistsException, WrongAttributeAssignmentException, ExtSourceNotExistsException, GroupNotExistsException, WrongAttributeValueException, WrongReferenceAttributeValueException { List<String> skippedGroups = new ArrayList<>(); ExtSource source = null; log.info("Group structure synchronization {}: started.", baseGroup); source = getGroupExtSourceForSynchronization(sess, baseGroup); List<CandidateGroup> candidateGroupsToAdd = new ArrayList<>(); Map<CandidateGroup, Group> groupsToUpdate = new HashMap<>(); List<Group> groupsToRemove = new ArrayList<>(); List<Group> actualGroups = getAllSubGroups(sess, baseGroup); List<Map<String, String>> subjectGroups = getSubjectGroupsFromExtSource(sess, source, baseGroup); if (isThisFlatSynchronization(sess, baseGroup)) { for(Map<String, String> subjectGroup : subjectGroups) { subjectGroup.put("parentGroupName", null); } } List<CandidateGroup> candidateGroups = getPerunBl().getExtSourcesManagerBl().getCandidateGroups(sess, subjectGroups, source); categorizeGroupsForSynchronization(actualGroups, candidateGroups, candidateGroupsToAdd, groupsToUpdate, groupsToRemove); addMissingGroupsWhileSynchronization(sess, baseGroup, candidateGroupsToAdd, skippedGroups); updateExistingGroupsWhileSynchronization(sess, baseGroup, groupsToUpdate, skippedGroups); removeFormerGroupsWhileSynchronization(sess, baseGroup, groupsToRemove, skippedGroups); log.info("Group structure synchronization {}: ended.", baseGroup); synchronizeSubGroupsMembers(sess, baseGroup, source); return skippedGroups; }

Target:
public List<String> synchronizeGroupStructure(PerunSession sess, Group baseGroup) throws InternalErrorException, AttributeNotExistsException, WrongAttributeAssignmentException, ExtSourceNotExistsException, GroupNotExistsException, WrongAttributeValueException, WrongReferenceAttributeValueException { List<String> skippedGroups = new ArrayList<>(); log.info("Group structure synchronization {}: started.", baseGroup); ExtSource source = getGroupExtSourceForSynchronization(sess, baseGroup); List<CandidateGroup> candidateGroupsToAdd = new ArrayList<>(); Map<CandidateGroup, Group> groupsToUpdate = new HashMap<>(); List<Group> groupsToRemove = new ArrayList<>(); List<Group> actualGroups = getAllSubGroups(sess, baseGroup); List<Map<String, String>> subjectGroups = getSubjectGroupsFromExtSource(sess, source, baseGroup); if (isThisFlatSynchronization(sess, baseGroup)) { for(Map<String, String> subjectGroup : subjectGroups) { subjectGroup.put(PARENT_GROUP_NAME, null); } } List<CandidateGroup> candidateGroups = getPerunBl().getExtSourcesManagerBl().generateCandidateGroups(sess, subjectGroups, source); categorizeGroupsForSynchronization(actualGroups, candidateGroups, candidateGroupsToAdd, groupsToUpdate, groupsToRemove); addMissingGroupsWhileSynchronization(sess, baseGroup, candidateGroupsToAdd, skippedGroups); updateExistingGroupsWhileSynchronization(sess, baseGroup, groupsToUpdate, skippedGroups); removeFormerGroupsWhileSynchronization(sess, baseGroup, groupsToRemove, skippedGroups); log.info("Group structure synchronization {}: ended.", baseGroup); synchronizeSubGroupsMembers(sess, baseGroup, source); return skippedGroups; }