Source:
public List<RichMember> convertMembersToRichMembersWithAttributes(PerunSession sess, List<RichMember> richMembers, Resource resource, List<AttributeDefinition> attrsDef) throws InternalErrorException, WrongAttributeAssignmentException { Facility facility = getPerunBl().getResourcesManagerBl().getFacility(sess, resource); List<AttributeDefinition> usersAttributesDef = new ArrayList<AttributeDefinition>(); List<AttributeDefinition> membersAttributesDef = new ArrayList<AttributeDefinition>(); List<AttributeDefinition> userFacilityAttributesDef = new ArrayList<AttributeDefinition>(); List<AttributeDefinition> memberResourceAttributesDef = new ArrayList<AttributeDefinition>(); List<String> attrNames = new ArrayList<>(); for(AttributeDefinition attributeDefinition: attrsDef) { attrNames.add(attributeDefinition.getName()); } for(AttributeDefinition attrd: attrsDef) { if(attrd.getName().startsWith(AttributesManager.NS_USER_ATTR)) usersAttributesDef.add(attrd); else if(attrd.getName().startsWith(AttributesManager.NS_USER_FACILITY_ATTR)) userFacilityAttributesDef.add(attrd); else if(attrd.getName().startsWith(AttributesManager.NS_MEMBER_ATTR)) membersAttributesDef.add(attrd); else if(attrd.getName().startsWith(AttributesManager.NS_MEMBER_RESOURCE_ATTR)) membersAttributesDef.add(attrd); } for (RichMember richMember: richMembers) { List<Attribute> userAttributes = new ArrayList<Attribute>(); List<Attribute> memberAttributes = new ArrayList<Attribute>(); List<Attribute> attributes = getPerunBl().getAttributesManagerBl().getAttributes(sess, resource, richMember, attrNames, true); for(Attribute attribute: attributes) { if(attribute.getNamespace().startsWith("urn:perun:user")) { userAttributes.add(attribute); } else if(attribute.getNamespace().startsWith("urn:perun:member")) { memberAttributes.add(attribute); } else { throw new InternalErrorException(attribute + " is not from user or member namespace (member-resource, user-facility included)!"); } } richMember.setUserAttributes(userAttributes); richMember.setMemberAttributes(memberAttributes); } return richMembers; }

Target:
public List<RichMember> convertMembersToRichMembersWithAttributes(PerunSession sess, List<RichMember> richMembers, Resource resource, List<AttributeDefinition> attrsDef) throws InternalErrorException, WrongAttributeAssignmentException { List<String> attrNames = new ArrayList<>(); for(AttributeDefinition attributeDefinition: attrsDef) { attrNames.add(attributeDefinition.getName()); } for (RichMember richMember: richMembers) { List<Attribute> userAttributes = new ArrayList<Attribute>(); List<Attribute> memberAttributes = new ArrayList<Attribute>(); List<Attribute> attributes = getPerunBl().getAttributesManagerBl().getAttributes(sess, resource, richMember, attrNames, true); for(Attribute attribute: attributes) { if(attribute.getName().startsWith(AttributesManager.NS_USER_ATTR)) userAttributes.add(attribute); else if(attribute.getName().startsWith(AttributesManager.NS_USER_FACILITY_ATTR)) userAttributes.add(attribute); else if(attribute.getName().startsWith(AttributesManager.NS_MEMBER_ATTR)) memberAttributes.add(attribute); else if(attribute.getName().startsWith(AttributesManager.NS_MEMBER_RESOURCE_ATTR)) memberAttributes.add(attribute); else { throw new InternalErrorException(attribute + " is not from user or member namespace (member-resource, user-facility included)!"); } } richMember.setUserAttributes(userAttributes); richMember.setMemberAttributes(memberAttributes); } return richMembers; }