2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
|
# File 'lib/gooddata/models/project.rb', line 2041
def check_groups(specified_groups, user_groups_cache = nil, options = {})
current_user_groups = user_groups if user_groups_cache.nil? || user_groups_cache.empty?
groups = current_user_groups.map(&:name)
missing_groups = []
change_groups = {}
specified_groups.each do |group|
found_group = groups.find { |name| name.casecmp(group).zero? }
if found_group.nil?
missing_groups << group
else
if found_group != group
change_groups[group] = found_group
GoodData.logger.warn("Group with name #{group} is existed in project with name #{found_group}.")
end
end
end
if options[:create_non_existing_user_groups]
missing_groups.each do |g|
GoodData.logger.info("Creating group #{g}")
create_group(name: g, description: g)
end
else
unless missing_groups.empty?
fail 'All groups have to be specified before you try to import ' \
'users. Groups that are currently in project are ' \
"#{groups.join(',')} and you asked for #{missing_groups.join(',')}"
end
end
[current_user_groups, change_groups]
end
|