Source:
<code>public List<RichGroup> convertGroupsToRichGroupsWithAttributes(PerunSession sess, Member member, Resource resource, List<Group> groups, List<String> attrNames) throws InternalErrorException, GroupResourceMismatchException, MemberResourceMismatchException { List<RichGroup> richGroups = new ArrayList<>(); for(Group group: groups) { List<Attribute> attributes = new ArrayList<>(); List<String> supportedNames = attrNames.stream().filter(attrName -> attrName.startsWith(AttributesManager.NS_GROUP_RESOURCE_ATTR) || attrName.startsWith(AttributesManager.NS_GROUP_ATTR)).collect(Collectors.toList() ); attributes.addAll(getPerunBl().getAttributesManagerBl().getAttributes(sess, resource, group, supportedNames, true)); supportedNames = attrNames.stream().filter(attrName -> attrName.startsWith(AttributesManager.NS_MEMBER_GROUP_ATTR)).collect(Collectors.toList() ); <START> if(supportedNames.isEmpty()) { <END> attributes.addAll(getPerunBl().getAttributesManagerBl().getAttributes(sess, member, group)); } else { attributes.addAll(getPerunBl().getAttributesManagerBl().getAttributes(sess, member, group, supportedNames)); } richGroups.add(new RichGroup(group, attributes)); } return richGroups; }</code><technical_language>this is consistent rest of API. this return member-group attributes, if caller eg. single group attribute in outer API call. check emptiness outer attrNames param filtered values. expectations for this specific method</technical_language>

Target:
public List<RichGroup> convertGroupsToRichGroupsWithAttributes(PerunSession sess, Member member, Resource resource, List<Group> groups, List<String> attrNames) throws InternalErrorException, GroupResourceMismatchException, MemberResourceMismatchException { List<RichGroup> richGroups = new ArrayList<>(); List<String> groupAndGroupResourceAttrNames = new ArrayList<>(); List<String> memberGroupAttrNames = new ArrayList<>(); if(attrNames != null && !attrNames.isEmpty()) { groupAndGroupResourceAttrNames = attrNames.stream().filter(attrName -> attrName.startsWith(AttributesManager.NS_GROUP_RESOURCE_ATTR) || attrName.startsWith(AttributesManager.NS_GROUP_ATTR)).collect(Collectors.toList()); memberGroupAttrNames = attrNames.stream().filter(attrName -> attrName.startsWith(AttributesManager.NS_MEMBER_GROUP_ATTR)).collect(Collectors.toList()); } for(Group group: groups) { if(attrNames == null) { List<Attribute> attributes = new ArrayList<>(); attributes.addAll(getPerunBl().getAttributesManagerBl().getAttributes(sess, resource, group, true)); attributes.addAll(getPerunBl().getAttributesManagerBl().getAttributes(sess, member, group)); richGroups.add(new RichGroup(group, attributes)); } else if (attrNames.isEmpty()) { richGroups.add(new RichGroup(group, new ArrayList<>())); } else { List<Attribute> attributes = new ArrayList<>(); if (!groupAndGroupResourceAttrNames.isEmpty()) attributes.addAll(getPerunBl().getAttributesManagerBl().getAttributes(sess, resource, group, groupAndGroupResourceAttrNames, true)); if (!memberGroupAttrNames.isEmpty()) attributes.addAll(getPerunBl().getAttributesManagerBl().getAttributes(sess, member, group, memberGroupAttrNames)); richGroups.add(new RichGroup(group, attributes)); } } return richGroups; }