use of cz.metacentrum.perun.core.api.Member in project perun by CESNET.
the class AttributesManagerBlImpl method getVoAttributes.
// ------------ PRIVATE METHODS FOR ATTRIBUTE DEPENDENCIES LOGIC --------------
// These methods get one or two Perun Beans and return list of richAttributes
// of specific type defined by name of method which actually exists in Perun
// and they are connected to the Perun Beans in parameters. If there is any
// possibility to filter them by members, use only allowed members connections.
// If member is not allowed (is in state Disabled or Invalid), remove
// all objects connected to him from structure for getting attributes.
//
// Example: We have USER and we want all GROUP attributes connected to this
// User. So we find all members connected to this user and only for those who
// are allowed (NOT have status DISABLED or INVALID we find all connected groups
// and then we find all group attributes for these groups and return them
// as RichAttributes.
// ----------------------------------------------------------------------------
// ---------------------------------VO-----------------------------------------
/**
* Returns all relevant Vo RichAttributes for given User.
* That means find all Vos where given user has allowed member.
* Each rich attribute is returned only once.
*
* @param sess session
* @param user user
* @param attrDef type of attribute that will be returned
* @return List of Rich attributes for given user
*/
private List<RichAttribute> getVoAttributes(PerunSession sess, User user, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
List<Member> membersFromUser = getPerunBl().getMembersManagerBl().getMembersByUser(sess, user);
for (Member memberElement : membersFromUser) {
listOfRichAttributes.addAll(getVoAttributes(sess, memberElement, attrDef));
}
listOfRichAttributes = new ArrayList<>(new HashSet<>(listOfRichAttributes));
return listOfRichAttributes;
}
use of cz.metacentrum.perun.core.api.Member in project perun by CESNET.
the class AttributesManagerBlImpl method getUserExtSourceAttributes.
/**
* Returns all relevant UserExtSource RichAttributes for given resource.
* Finds allowed members for the given resource.
* Finds theirs user's userExtSources and returns theirs rich attributes.
* Each rich attribute is returned only once.
*
* @param sess session
* @param resource resource
* @param attrDef type of attribute that will be returned
* @return List of RichAttribute
*/
private List<RichAttribute> getUserExtSourceAttributes(PerunSession sess, Resource resource, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
List<Member> resourceMembers = getPerunBl().getResourcesManagerBl().getAllowedMembers(sess, resource);
for (Member memberElement : resourceMembers) {
listOfRichAttributes.addAll(getUserExtSourceAttributes(sess, memberElement, attrDef));
}
listOfRichAttributes = new ArrayList<>(new HashSet<>(listOfRichAttributes));
return listOfRichAttributes;
}
use of cz.metacentrum.perun.core.api.Member in project perun by CESNET.
the class AttributesManagerEntryIntegrationTest method getRequiredMemberAttributesFromOneServiceWhenMemberNotExists.
@Test(expected = MemberNotExistsException.class)
public void getRequiredMemberAttributesFromOneServiceWhenMemberNotExists() throws Exception {
System.out.println(CLASS_NAME + "getRequiredMemberAttributesFromOneServiceWhenMemberNotExists");
service = setUpService();
attributesManager.getRequiredAttributes(sess, service, new Member());
// shouldn't find member
}
use of cz.metacentrum.perun.core.api.Member in project perun by CESNET.
the class AttributesManagerBlImplUnitTests method getRequiredAttributes_services_f_r_u_m.
@Test
public void getRequiredAttributes_services_f_r_u_m() throws Exception {
System.out.println(CLASS_NAME + "getRequiredAttributes_services_f_r_u_m");
Service s1 = new Service(1, "s1");
Service s2 = new Service(2, "s2");
List<Service> services = Arrays.asList(s1, s2);
Facility facility = new Facility(1, "f");
Resource resource = new Resource(2, "r", "", facility.getId());
User user = new User(3, "a", "b", "", "", "");
Member member = new Member(4, user.getId());
Attribute a1 = new Attribute(new AttributeDefinition(), 1);
Attribute a2 = new Attribute(new AttributeDefinition(), 2);
Attribute a3 = new Attribute(new AttributeDefinition(), 3);
List<Attribute> s1Attributes = Arrays.asList(a1, a2);
List<Attribute> s2Attributes = Arrays.asList(a2, a3);
doCallRealMethod().when(attrManagerBlImplMock).getRequiredAttributes(sessionMock, services, facility, resource, user, member);
when(attrManagerBlImplMock.getRequiredAttributes(sessionMock, s1, facility, resource, user, member)).thenReturn(s1Attributes);
when(attrManagerBlImplMock.getRequiredAttributes(sessionMock, s2, facility, resource, user, member)).thenReturn(s2Attributes);
List<Attribute> returnedAttributes = attrManagerBlImplMock.getRequiredAttributes(sessionMock, services, facility, resource, user, member);
assertThat(returnedAttributes).containsExactlyInAnyOrder(a1, a2, a3);
}
use of cz.metacentrum.perun.core.api.Member in project perun by CESNET.
the class urn_perun_member_group_attribute_def_virt_isGroupAdminTest method setUpMember.
private Member setUpMember(Vo vo) throws Exception {
Member newMember = membersManager.createMember(sess, vo, user);
assertNotNull(newMember);
return newMember;
}
Aggregations