Search in sources :

Example 6 with Member

use of cz.metacentrum.perun.core.api.Member in project perun by CESNET.

the class FacilitiesManagerBlImpl method getFacilitiesByPerunBean.

public List<Facility> getFacilitiesByPerunBean(PerunSession sess, PerunBean perunBean) throws InternalErrorException {
    List<Facility> facilities = new ArrayList<Facility>();
    //All possible useful objects
    Vo vo = null;
    Facility facility = null;
    Group group = null;
    Member member = null;
    User user = null;
    Host host = null;
    Resource resource = null;
    if (perunBean != null) {
        if (perunBean instanceof Vo)
            vo = (Vo) perunBean;
        else if (perunBean instanceof Facility)
            facility = (Facility) perunBean;
        else if (perunBean instanceof Group)
            group = (Group) perunBean;
        else if (perunBean instanceof Member)
            member = (Member) perunBean;
        else if (perunBean instanceof User)
            user = (User) perunBean;
        else if (perunBean instanceof Host)
            host = (Host) perunBean;
        else if (perunBean instanceof Resource)
            resource = (Resource) perunBean;
        else {
            throw new InternalErrorException("There is unrecognized object in primaryHolder of aidingAttr.");
        }
    } else {
        throw new InternalErrorException("Aiding attribtue must have primaryHolder which is not null.");
    }
    if (group != null) {
        List<Resource> resources = getPerunBl().getResourcesManagerBl().getAssignedResources(sess, group);
        for (Resource resourceElemenet : resources) {
            facilities.add(getPerunBl().getResourcesManagerBl().getFacility(sess, resourceElemenet));
        }
    } else if (member != null) {
        List<Group> groupsForMember = getPerunBl().getGroupsManagerBl().getAllMemberGroups(sess, member);
        List<Resource> resourcesFromMember = new ArrayList<Resource>();
        for (Group groupElement : groupsForMember) {
            resourcesFromMember.addAll(getPerunBl().getResourcesManagerBl().getAssignedResources(sess, groupElement));
        }
        for (Resource resourceElement : resourcesFromMember) {
            facilities.add(getPerunBl().getResourcesManagerBl().getFacility(sess, resourceElement));
        }
    } else if (resource != null) {
        facilities.add(getPerunBl().getResourcesManagerBl().getFacility(sess, resource));
    } else if (user != null) {
        List<Member> membersFromUser = getPerunBl().getMembersManagerBl().getMembersByUser(sess, user);
        List<Resource> resourcesFromMembers = new ArrayList<Resource>();
        for (Member memberElement : membersFromUser) {
            resourcesFromMembers.addAll(getPerunBl().getResourcesManagerBl().getAssignedResources(sess, member));
        }
        for (Resource resourceElement : resourcesFromMembers) {
            facilities.add(getPerunBl().getResourcesManagerBl().getFacility(sess, resourceElement));
        }
    } else if (host != null) {
        facilities.add(getPerunBl().getFacilitiesManagerBl().getFacilityForHost(sess, host));
    } else if (vo != null) {
        List<Resource> resources = getPerunBl().getResourcesManagerBl().getResources(sess, vo);
        for (Resource resourceElemenet : resources) {
            facilities.add(getPerunBl().getResourcesManagerBl().getFacility(sess, resourceElemenet));
        }
    }
    facilities = new ArrayList<Facility>(new HashSet<Facility>(facilities));
    return facilities;
}
Also used : Group(cz.metacentrum.perun.core.api.Group) ContactGroup(cz.metacentrum.perun.core.api.ContactGroup) User(cz.metacentrum.perun.core.api.User) RichUser(cz.metacentrum.perun.core.api.RichUser) ArrayList(java.util.ArrayList) Resource(cz.metacentrum.perun.core.api.Resource) RichResource(cz.metacentrum.perun.core.api.RichResource) Host(cz.metacentrum.perun.core.api.Host) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) Vo(cz.metacentrum.perun.core.api.Vo) List(java.util.List) ArrayList(java.util.ArrayList) BanOnFacility(cz.metacentrum.perun.core.api.BanOnFacility) Facility(cz.metacentrum.perun.core.api.Facility) RichFacility(cz.metacentrum.perun.core.api.RichFacility) Member(cz.metacentrum.perun.core.api.Member) HashSet(java.util.HashSet)

Example 7 with Member

use of cz.metacentrum.perun.core.api.Member in project perun by CESNET.

the class urn_perun_member_resource_attribute_def_virt_isBanned method resolveVirtualAttributeValueChange.

@Override
public List<String> resolveVirtualAttributeValueChange(PerunSessionImpl perunSession, String message) throws InternalErrorException, WrongReferenceAttributeValueException, AttributeNotExistsException, WrongAttributeAssignmentException {
    List<String> resolvingMessages = new ArrayList<>();
    if (message == null)
        return resolvingMessages;
    Matcher banModificationMatcher = banModification.matcher(message);
    List<Pair<Resource, Member>> listOfAffectedObjects = new ArrayList<>();
    String operationType = "";
    if (banModificationMatcher.find()) {
        try {
            String banType = banModificationMatcher.group(1);
            operationType = banModificationMatcher.group(2);
            int firstHolderId = Integer.valueOf(banModificationMatcher.group(3));
            int secondHolderId = Integer.valueOf(banModificationMatcher.group(4));
            if (operationType.equals(OPERATION_UPDATED)) {
                operationType = OPERATION_SET;
            } else if (!operationType.equals(OPERATION_SET) && !operationType.equals(OPERATION_REMOVED)) {
                throw new InternalErrorException("Type of operation '" + operationType + "' is unknown by module.");
            }
            if (banType.equals(BanOnResource.class.getSimpleName())) {
                Member member = perunSession.getPerunBl().getMembersManagerBl().getMemberById(perunSession, firstHolderId);
                Resource resource = perunSession.getPerunBl().getResourcesManagerBl().getResourceById(perunSession, secondHolderId);
                listOfAffectedObjects.add(new Pair(resource, member));
            } else if (banType.equals(BanOnFacility.class.getSimpleName())) {
                User user = perunSession.getPerunBl().getUsersManagerBl().getUserById(perunSession, firstHolderId);
                Facility facility = perunSession.getPerunBl().getFacilitiesManagerBl().getFacilityById(perunSession, secondHolderId);
                listOfAffectedObjects = getAffectedMemberResourceObjects(perunSession, user, facility);
            } else {
                throw new InternalErrorException("Type of ban '" + banType + "' is unkown by module.");
            }
        } catch (Exception e) {
            log.error("Can't resolve virtual attribute value change for " + this.getClass().getSimpleName() + " module because of exception.", e);
            //return empty array, do not throw exception because it can create problems
            return new ArrayList<>();
        }
    }
    for (Pair<Resource, Member> affectedObjects : listOfAffectedObjects) {
        try {
            Attribute attrVirtMemberResourceIsBanned = perunSession.getPerunBl().getAttributesManagerBl().getAttribute(perunSession, affectedObjects.getLeft(), affectedObjects.getRight(), AttributesManager.NS_MEMBER_RESOURCE_ATTR_VIRT + ":isBanned");
            resolvingMessages.add(attrVirtMemberResourceIsBanned.serializeToString() + " " + operationType + " for " + affectedObjects.getLeft().serializeToString() + " and " + affectedObjects.getRight().serializeToString());
        } catch (AttributeNotExistsException ex) {
            //This means that attribute isBanned not exists at all so we can skip this process
            log.info("Virtual attribute {} not exists.", this.getClass().getSimpleName());
            break;
        }
    }
    return resolvingMessages;
}
Also used : User(cz.metacentrum.perun.core.api.User) Matcher(java.util.regex.Matcher) Attribute(cz.metacentrum.perun.core.api.Attribute) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) ArrayList(java.util.ArrayList) Resource(cz.metacentrum.perun.core.api.Resource) BanOnResource(cz.metacentrum.perun.core.api.BanOnResource) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) WrongReferenceAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) FacilityNotExistsException(cz.metacentrum.perun.core.api.exceptions.FacilityNotExistsException) UserNotExistsException(cz.metacentrum.perun.core.api.exceptions.UserNotExistsException) WrongAttributeAssignmentException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException) BanOnResource(cz.metacentrum.perun.core.api.BanOnResource) BanOnFacility(cz.metacentrum.perun.core.api.BanOnFacility) Facility(cz.metacentrum.perun.core.api.Facility) Member(cz.metacentrum.perun.core.api.Member) Pair(cz.metacentrum.perun.core.api.Pair)

Example 8 with Member

use of cz.metacentrum.perun.core.api.Member in project perun by CESNET.

the class FacilitiesManagerEntryIntegrationTest method addFacilityContactForAll2.

@Test
public void addFacilityContactForAll2() throws Exception {
    System.out.println(CLASS_NAME + "addFacilityContactForAll2");
    Member member = setUpMember(vo);
    Group group = setUpGroup(vo, member);
    User user = perun.getUsersManagerBl().getUserByMember(sess, member);
    String contactGroupName = "testContactGroup01";
    ContactGroup cg = new ContactGroup(contactGroupName, facility);
    cg.setOwners(new ArrayList<>(Arrays.asList(owner)));
    cg.setGroups(new ArrayList<>(Arrays.asList(group)));
    RichUser richUser = new RichUser(user, null);
    List<RichUser> users = perun.getUsersManagerBl().convertUsersToRichUsersWithAttributes(sess, Arrays.asList(richUser), getMandatoryAttrs());
    cg.setUsers(new ArrayList<>(users));
    facilitiesManagerEntry.addFacilityContact(sess, cg);
    List<ContactGroup> cgs = facilitiesManagerEntry.getFacilityContactGroups(sess, facility);
    assertTrue(cg.equals(cgs.get(0)));
    assertEquals(owner.getId(), cgs.get(0).getOwners().get(0).getId());
    assertEquals(group.getId(), cgs.get(0).getGroups().get(0).getId());
    assertEquals(user.getId(), cgs.get(0).getUsers().get(0).getId());
}
Also used : Group(cz.metacentrum.perun.core.api.Group) ContactGroup(cz.metacentrum.perun.core.api.ContactGroup) User(cz.metacentrum.perun.core.api.User) RichUser(cz.metacentrum.perun.core.api.RichUser) RichUser(cz.metacentrum.perun.core.api.RichUser) ContactGroup(cz.metacentrum.perun.core.api.ContactGroup) Member(cz.metacentrum.perun.core.api.Member) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 9 with Member

use of cz.metacentrum.perun.core.api.Member in project perun by CESNET.

the class VOOT method isMemberOf.

/**
	 * Return groups that user is member of.
	 *
	 * @return                  groups that user is member of
	 * @throws VOOTException    if the can not read groups of user
	 */
private List<Group> isMemberOf() throws VOOTException {
    List<Group> groups = new ArrayList<Group>();
    List<Vo> vos = new ArrayList<Vo>();
    try {
        vos.addAll(perun.getUsersManagerBl().getVosWhereUserIsMember(session, user));
    } catch (InternalErrorException ex) {
        throw new VOOTException("internal_server_error");
    }
    try {
        for (Vo vo : vos) {
            Member member = perun.getMembersManagerBl().getMemberByUser(session, vo, user);
            groups.addAll(perun.getGroupsManagerBl().getAllMemberGroups(session, member));
        }
    } catch (InternalErrorException ex) {
        throw new VOOTException("internal_server_error");
    } catch (MemberNotExistsException ex) {
        throw new VOOTException("not_a_member");
    }
    return groups;
}
Also used : Group(cz.metacentrum.perun.core.api.Group) MemberNotExistsException(cz.metacentrum.perun.core.api.exceptions.MemberNotExistsException) ArrayList(java.util.ArrayList) Vo(cz.metacentrum.perun.core.api.Vo) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) Member(cz.metacentrum.perun.core.api.Member)

Example 10 with Member

use of cz.metacentrum.perun.core.api.Member in project perun by CESNET.

the class AttributesManagerBlImpl method getRichAttributesWithHoldersForAttributeDefinition.

@Override
public List<RichAttribute> getRichAttributesWithHoldersForAttributeDefinition(PerunSession sess, AttributeDefinition attrDef, RichAttribute aidingAttr) throws AttributeNotExistsException, UserNotExistsException, VoNotExistsException, WrongAttributeAssignmentException, GroupResourceMismatchException, MemberResourceMismatchException, MemberGroupMismatchException {
    // Filling objects from aidingAttr
    if (aidingAttr == null)
        throw new InternalErrorException("Aiding attribute cant be null.");
    if (attrDef == null)
        throw new InternalErrorException("attrDef cant be null.");
    List<RichAttribute> listOfRichAttributes = new ArrayList<>();
    // All possible useful objects
    Vo vo = null;
    Facility facility = null;
    Group group = null;
    Member member = null;
    User user = null;
    Host host = null;
    Resource resource = null;
    String key = null;
    UserExtSource userExtSource = null;
    // Get object for primaryHolder of aidingAttr
    if (aidingAttr.getPrimaryHolder() != null) {
        if (aidingAttr.getPrimaryHolder() instanceof Vo)
            vo = (Vo) aidingAttr.getPrimaryHolder();
        else if (aidingAttr.getPrimaryHolder() instanceof Facility)
            facility = (Facility) aidingAttr.getPrimaryHolder();
        else if (aidingAttr.getPrimaryHolder() instanceof Group)
            group = (Group) aidingAttr.getPrimaryHolder();
        else if (aidingAttr.getPrimaryHolder() instanceof Member)
            member = (Member) aidingAttr.getPrimaryHolder();
        else if (aidingAttr.getPrimaryHolder() instanceof User)
            user = (User) aidingAttr.getPrimaryHolder();
        else if (aidingAttr.getPrimaryHolder() instanceof Host)
            host = (Host) aidingAttr.getPrimaryHolder();
        else if (aidingAttr.getPrimaryHolder() instanceof Resource)
            resource = (Resource) aidingAttr.getPrimaryHolder();
        else if (aidingAttr.getPrimaryHolder() instanceof UserExtSource)
            userExtSource = (UserExtSource) aidingAttr.getPrimaryHolder();
        else if (aidingAttr.getPrimaryHolder() instanceof String)
            key = (String) aidingAttr.getPrimaryHolder();
        else {
            throw new InternalErrorException("There is unrecognized object in primaryHolder of aidingAttr.");
        }
    } else {
        throw new InternalErrorException("Aiding attribute must have primaryHolder which is not null.");
    }
    // Get object for secondaryHolder of aidingAttr
    if (aidingAttr.getSecondaryHolder() != null) {
        if (aidingAttr.getSecondaryHolder() instanceof Vo)
            vo = (Vo) aidingAttr.getSecondaryHolder();
        else if (aidingAttr.getSecondaryHolder() instanceof Facility)
            facility = (Facility) aidingAttr.getSecondaryHolder();
        else if (aidingAttr.getSecondaryHolder() instanceof Group)
            group = (Group) aidingAttr.getSecondaryHolder();
        else if (aidingAttr.getSecondaryHolder() instanceof Member)
            member = (Member) aidingAttr.getSecondaryHolder();
        else if (aidingAttr.getSecondaryHolder() instanceof User)
            user = (User) aidingAttr.getSecondaryHolder();
        else if (aidingAttr.getSecondaryHolder() instanceof Host)
            host = (Host) aidingAttr.getSecondaryHolder();
        else if (aidingAttr.getSecondaryHolder() instanceof Resource)
            resource = (Resource) aidingAttr.getSecondaryHolder();
        else if (aidingAttr.getSecondaryHolder() instanceof UserExtSource)
            userExtSource = (UserExtSource) aidingAttr.getSecondaryHolder();
        else if (aidingAttr.getSecondaryHolder() instanceof String)
            key = (String) aidingAttr.getSecondaryHolder();
        else {
            throw new InternalErrorException("There is unrecognized object in secondaryHolder of aidingAttr");
        }
    }
    if (getAttributesManagerImpl().isFromNamespace(attrDef, NS_VO_ATTR)) {
        if (resource != null && member != null) {
            // we do not need object resource to resolve this case
            listOfRichAttributes.addAll(this.getVoAttributes(sess, member, attrDef));
        } else if (group != null && resource != null) {
            // we do not need object resource to resolve this case
            listOfRichAttributes.addAll(this.getVoAttributes(sess, group, attrDef));
        } else if (user != null && facility != null) {
            listOfRichAttributes.addAll(this.getVoAttributes(sess, user, facility, attrDef));
        } else if (member != null && group != null) {
            // we do not need object group to resolve this case
            listOfRichAttributes.addAll(this.getVoAttributes(sess, member, attrDef));
        } else if (group != null) {
            listOfRichAttributes.addAll(this.getVoAttributes(sess, group, attrDef));
        } else if (member != null) {
            listOfRichAttributes.addAll(this.getVoAttributes(sess, member, attrDef));
        } else if (resource != null) {
            listOfRichAttributes.addAll(this.getVoAttributes(sess, resource, attrDef));
        } else if (user != null) {
            listOfRichAttributes.addAll(this.getVoAttributes(sess, user, attrDef));
        } else if (host != null) {
            listOfRichAttributes.addAll(this.getVoAttributes(sess, host, attrDef));
        } else if (facility != null) {
            listOfRichAttributes.addAll(this.getVoAttributes(sess, facility, attrDef));
        } else if (vo != null) {
            listOfRichAttributes.addAll(this.getVoAttributes(sess, vo, attrDef));
        } else if (userExtSource != null) {
            listOfRichAttributes.addAll(this.getVoAttributes(sess, userExtSource, attrDef));
        } else if (key != null) {
            listOfRichAttributes.addAll(this.getVoAttributes(sess, attrDef));
        } else {
            throw new InternalErrorException("Unknown combination of PerunBeans: " + aidingAttr);
        }
    } else if (getAttributesManagerImpl().isFromNamespace(attrDef, NS_GROUP_ATTR)) {
        if (resource != null && member != null) {
            listOfRichAttributes.addAll(this.getGroupAttributes(sess, member, resource, attrDef));
        } else if (group != null && resource != null) {
            // we do not need to use the resource object here
            listOfRichAttributes.addAll(this.getGroupAttributes(sess, group, attrDef));
        } else if (user != null && facility != null) {
            listOfRichAttributes.addAll(this.getGroupAttributes(sess, user, facility, attrDef));
        } else if (member != null && group != null) {
            listOfRichAttributes.addAll(this.getGroupAttributes(sess, member, group, attrDef));
        } else if (group != null) {
            listOfRichAttributes.addAll(this.getGroupAttributes(sess, group, attrDef));
        } else if (member != null) {
            listOfRichAttributes.addAll(this.getGroupAttributes(sess, member, attrDef));
        } else if (resource != null) {
            listOfRichAttributes.addAll(this.getGroupAttributes(sess, resource, attrDef));
        } else if (user != null) {
            listOfRichAttributes.addAll(this.getGroupAttributes(sess, user, attrDef));
        } else if (host != null) {
            listOfRichAttributes.addAll(this.getGroupAttributes(sess, host, attrDef));
        } else if (facility != null) {
            listOfRichAttributes.addAll(this.getGroupAttributes(sess, facility, attrDef));
        } else if (vo != null) {
            listOfRichAttributes.addAll(this.getGroupAttributes(sess, vo, attrDef));
        } else if (userExtSource != null) {
            listOfRichAttributes.addAll(this.getGroupAttributes(sess, userExtSource, attrDef));
        } else if (key != null) {
            listOfRichAttributes.addAll(this.getGroupAttributes(sess, attrDef));
        } else {
            throw new InternalErrorException("Unknown combination of PerunBeans: " + aidingAttr);
        }
    } else if (getAttributesManagerImpl().isFromNamespace(attrDef, NS_FACILITY_ATTR)) {
        if (resource != null && member != null) {
            listOfRichAttributes.addAll(this.getFacilityAttributes(sess, member, resource, attrDef));
        } else if (group != null && resource != null) {
            // we do not need to use the group object here
            listOfRichAttributes.addAll(this.getFacilityAttributes(sess, resource, attrDef));
        } else if (user != null && facility != null) {
            listOfRichAttributes.addAll(this.getFacilityAttributes(sess, user, facility, attrDef));
        } else if (member != null && group != null) {
            listOfRichAttributes.addAll(this.getFacilityAttributes(sess, member, group, attrDef));
        } else if (group != null) {
            listOfRichAttributes.addAll(this.getFacilityAttributes(sess, group, attrDef));
        } else if (member != null) {
            listOfRichAttributes.addAll(this.getFacilityAttributes(sess, member, attrDef));
        } else if (resource != null) {
            listOfRichAttributes.addAll(this.getFacilityAttributes(sess, resource, attrDef));
        } else if (user != null) {
            listOfRichAttributes.addAll(this.getFacilityAttributes(sess, user, attrDef));
        } else if (host != null) {
            listOfRichAttributes.addAll(this.getFacilityAttributes(sess, host, attrDef));
        } else if (facility != null) {
            listOfRichAttributes.addAll(this.getFacilityAttributes(sess, facility, attrDef));
        } else if (vo != null) {
            listOfRichAttributes.addAll(this.getFacilityAttributes(sess, vo, attrDef));
        } else if (userExtSource != null) {
            listOfRichAttributes.addAll(this.getFacilityAttributes(sess, userExtSource, attrDef));
        } else if (key != null) {
            listOfRichAttributes.addAll(this.getFacilityAttributes(sess, attrDef));
        } else {
            throw new InternalErrorException("Unknown combination of PerunBeans: " + aidingAttr);
        }
    } else if (getAttributesManagerImpl().isFromNamespace(attrDef, NS_MEMBER_ATTR)) {
        if (resource != null && member != null) {
            // we do not need to use the resource object here
            listOfRichAttributes.addAll(this.getMemberAttributes(sess, member, attrDef));
        } else if (group != null && resource != null) {
            // we do not need to use the resource object here
            listOfRichAttributes.addAll(this.getMemberAttributes(sess, group, attrDef));
        } else if (user != null && facility != null) {
            listOfRichAttributes.addAll(this.getMemberAttributes(sess, user, facility, attrDef));
        } else if (member != null && group != null) {
            // we do not need to use the group object here
            listOfRichAttributes.addAll(this.getMemberAttributes(sess, member, attrDef));
        } else if (group != null) {
            listOfRichAttributes.addAll(this.getMemberAttributes(sess, group, attrDef));
        } else if (member != null) {
            listOfRichAttributes.addAll(this.getMemberAttributes(sess, member, attrDef));
        } else if (resource != null) {
            listOfRichAttributes.addAll(this.getMemberAttributes(sess, resource, attrDef));
        } else if (user != null) {
            listOfRichAttributes.addAll(this.getMemberAttributes(sess, user, attrDef));
        } else if (host != null) {
            listOfRichAttributes.addAll(this.getMemberAttributes(sess, host, attrDef));
        } else if (facility != null) {
            listOfRichAttributes.addAll(this.getMemberAttributes(sess, facility, attrDef));
        } else if (vo != null) {
            listOfRichAttributes.addAll(this.getMemberAttributes(sess, vo, attrDef));
        } else if (userExtSource != null) {
            listOfRichAttributes.addAll(this.getMemberAttributes(sess, userExtSource, attrDef));
        } else if (key != null) {
            listOfRichAttributes.addAll(this.getMemberAttributes(sess, attrDef));
        } else {
            throw new InternalErrorException("Unknown combination of PerunBeans: " + aidingAttr);
        }
    } else if (getAttributesManagerImpl().isFromNamespace(attrDef, NS_RESOURCE_ATTR)) {
        if (resource != null && member != null) {
            listOfRichAttributes.addAll(this.getResourceAttributes(sess, member, resource, attrDef));
        } else if (group != null && resource != null) {
            // we do not need to use the group object here
            listOfRichAttributes.addAll(this.getResourceAttributes(sess, resource, attrDef));
        } else if (user != null && facility != null) {
            listOfRichAttributes.addAll(this.getResourceAttributes(sess, user, facility, attrDef));
        } else if (member != null && group != null) {
            listOfRichAttributes.addAll(this.getResourceAttributes(sess, member, group, attrDef));
        } else if (group != null) {
            listOfRichAttributes.addAll(this.getResourceAttributes(sess, group, attrDef));
        } else if (member != null) {
            listOfRichAttributes.addAll(this.getResourceAttributes(sess, member, attrDef));
        } else if (resource != null) {
            listOfRichAttributes.addAll(this.getResourceAttributes(sess, resource, attrDef));
        } else if (user != null) {
            listOfRichAttributes.addAll(this.getResourceAttributes(sess, user, attrDef));
        } else if (host != null) {
            listOfRichAttributes.addAll(this.getResourceAttributes(sess, host, attrDef));
        } else if (facility != null) {
            listOfRichAttributes.addAll(this.getResourceAttributes(sess, facility, attrDef));
        } else if (vo != null) {
            listOfRichAttributes.addAll(this.getResourceAttributes(sess, vo, attrDef));
        } else if (userExtSource != null) {
            listOfRichAttributes.addAll(this.getResourceAttributes(sess, userExtSource, attrDef));
        } else if (key != null) {
            listOfRichAttributes.addAll(this.getResourceAttributes(sess, attrDef));
        } else {
            throw new InternalErrorException("Unknown combination of PerunBeans: " + aidingAttr);
        }
    } else if (getAttributesManagerImpl().isFromNamespace(attrDef, NS_USER_ATTR)) {
        if (resource != null && member != null) {
            // we do not need to use the resource object here
            listOfRichAttributes.addAll(this.getUserAttributes(sess, member, attrDef));
        } else if (group != null && resource != null) {
            // we do not need to use the resource object here
            listOfRichAttributes.addAll(this.getUserAttributes(sess, group, attrDef));
        } else if (user != null && facility != null) {
            listOfRichAttributes.addAll(this.getUserAttributes(sess, user, facility, attrDef));
        } else if (member != null && group != null) {
            // we do not need to use the group object here
            listOfRichAttributes.addAll(this.getUserAttributes(sess, member, attrDef));
        } else if (group != null) {
            listOfRichAttributes.addAll(this.getUserAttributes(sess, group, attrDef));
        } else if (member != null) {
            listOfRichAttributes.addAll(this.getUserAttributes(sess, member, attrDef));
        } else if (resource != null) {
            listOfRichAttributes.addAll(this.getUserAttributes(sess, resource, attrDef));
        } else if (user != null) {
            listOfRichAttributes.addAll(this.getUserAttributes(sess, user, attrDef));
        } else if (host != null) {
            listOfRichAttributes.addAll(this.getUserAttributes(sess, host, attrDef));
        } else if (facility != null) {
            listOfRichAttributes.addAll(this.getUserAttributes(sess, facility, attrDef));
        } else if (vo != null) {
            listOfRichAttributes.addAll(this.getUserAttributes(sess, vo, attrDef));
        } else if (userExtSource != null) {
            listOfRichAttributes.addAll(this.getUserAttributes(sess, userExtSource, attrDef));
        } else if (key != null) {
            listOfRichAttributes.addAll(this.getUserAttributes(sess, attrDef));
        } else {
            throw new InternalErrorException("Unknown combination of PerunBeans: " + aidingAttr);
        }
    } else if (getAttributesManagerImpl().isFromNamespace(attrDef, AttributesManager.NS_HOST_ATTR)) {
        if (resource != null && member != null) {
            listOfRichAttributes.addAll(this.getHostAttributes(sess, member, resource, attrDef));
        } else if (group != null && resource != null) {
            // we do not need to user the group object here
            listOfRichAttributes.addAll(this.getHostAttributes(sess, resource, attrDef));
        } else if (user != null && facility != null) {
            listOfRichAttributes.addAll(this.getHostAttributes(sess, user, facility, attrDef));
        } else if (member != null && group != null) {
            listOfRichAttributes.addAll(this.getHostAttributes(sess, member, group, attrDef));
        } else if (group != null) {
            listOfRichAttributes.addAll(this.getHostAttributes(sess, group, attrDef));
        } else if (member != null) {
            listOfRichAttributes.addAll(this.getHostAttributes(sess, member, attrDef));
        } else if (resource != null) {
            listOfRichAttributes.addAll(this.getHostAttributes(sess, resource, attrDef));
        } else if (user != null) {
            listOfRichAttributes.addAll(this.getHostAttributes(sess, user, attrDef));
        } else if (host != null) {
            listOfRichAttributes.addAll(this.getHostAttributes(sess, host, attrDef));
        } else if (facility != null) {
            listOfRichAttributes.addAll(this.getHostAttributes(sess, facility, attrDef));
        } else if (vo != null) {
            listOfRichAttributes.addAll(this.getHostAttributes(sess, vo, attrDef));
        } else if (userExtSource != null) {
            listOfRichAttributes.addAll(this.getHostAttributes(sess, userExtSource, attrDef));
        } else if (key != null) {
            listOfRichAttributes.addAll(this.getHostAttributes(sess, attrDef));
        } else {
            throw new InternalErrorException("Unknown combination of PerunBeans: " + aidingAttr);
        }
    } else if (getAttributesManagerImpl().isFromNamespace(attrDef, NS_GROUP_RESOURCE_ATTR)) {
        if (resource != null && member != null) {
            listOfRichAttributes.addAll(this.getGroupResourceAttributes(sess, member, resource, attrDef));
        } else if (group != null && resource != null) {
            listOfRichAttributes.addAll(this.getGroupResourceAttributes(sess, group, resource, attrDef));
        } else if (user != null && facility != null) {
            listOfRichAttributes.addAll(this.getGroupResourceAttributes(sess, user, facility, attrDef));
        } else if (member != null && group != null) {
            listOfRichAttributes.addAll(this.getGroupResourceAttributes(sess, member, group, attrDef));
        } else if (group != null) {
            listOfRichAttributes.addAll(this.getGroupResourceAttributes(sess, group, attrDef));
        } else if (member != null) {
            listOfRichAttributes.addAll(this.getGroupResourceAttributes(sess, member, attrDef));
        } else if (resource != null) {
            listOfRichAttributes.addAll(this.getGroupResourceAttributes(sess, resource, attrDef));
        } else if (user != null) {
            listOfRichAttributes.addAll(this.getGroupResourceAttributes(sess, user, attrDef));
        } else if (host != null) {
            listOfRichAttributes.addAll(this.getGroupResourceAttributes(sess, host, attrDef));
        } else if (facility != null) {
            listOfRichAttributes.addAll(this.getGroupResourceAttributes(sess, facility, attrDef));
        } else if (vo != null) {
            listOfRichAttributes.addAll(this.getGroupResourceAttributes(sess, vo, attrDef));
        } else if (userExtSource != null) {
            listOfRichAttributes.addAll(this.getGroupResourceAttributes(sess, userExtSource, attrDef));
        } else if (key != null) {
            listOfRichAttributes.addAll(this.getGroupResourceAttributes(sess, attrDef));
        } else {
            throw new InternalErrorException("Unknown combination of PerunBeans: " + aidingAttr);
        }
    } else if (getAttributesManagerImpl().isFromNamespace(attrDef, NS_MEMBER_GROUP_ATTR)) {
        if (resource != null && member != null) {
            listOfRichAttributes.addAll(this.getMemberGroupAttributes(sess, member, resource, attrDef));
        } else if (group != null && resource != null) {
            // we do not need to use the resource object
            listOfRichAttributes.addAll(this.getMemberGroupAttributes(sess, group, attrDef));
        } else if (user != null && facility != null) {
            listOfRichAttributes.addAll(this.getMemberGroupAttributes(sess, user, facility, attrDef));
        } else if (member != null && group != null) {
            listOfRichAttributes.addAll(this.getMemberGroupAttributes(sess, member, group, attrDef));
        } else if (group != null) {
            listOfRichAttributes.addAll(this.getMemberGroupAttributes(sess, group, attrDef));
        } else if (member != null) {
            listOfRichAttributes.addAll(this.getMemberGroupAttributes(sess, member, attrDef));
        } else if (resource != null) {
            listOfRichAttributes.addAll(this.getMemberGroupAttributes(sess, resource, attrDef));
        } else if (user != null) {
            listOfRichAttributes.addAll(this.getMemberGroupAttributes(sess, user, attrDef));
        } else if (host != null) {
            listOfRichAttributes.addAll(this.getMemberGroupAttributes(sess, host, attrDef));
        } else if (facility != null) {
            listOfRichAttributes.addAll(this.getMemberGroupAttributes(sess, facility, attrDef));
        } else if (vo != null) {
            listOfRichAttributes.addAll(this.getMemberGroupAttributes(sess, vo, attrDef));
        } else if (userExtSource != null) {
            listOfRichAttributes.addAll(this.getMemberGroupAttributes(sess, userExtSource, attrDef));
        } else if (key != null) {
            listOfRichAttributes.addAll(this.getMemberGroupAttributes(sess, attrDef));
        } else {
            throw new InternalErrorException("Unknown combination of PerunBeans: " + aidingAttr);
        }
    } else if (getAttributesManagerImpl().isFromNamespace(attrDef, NS_MEMBER_RESOURCE_ATTR)) {
        if (resource != null && member != null) {
            listOfRichAttributes.addAll(this.getMemberResourceAttributes(sess, member, resource, attrDef));
        } else if (group != null && resource != null) {
            listOfRichAttributes.addAll(this.getMemberResourceAttributes(sess, group, resource, attrDef));
        } else if (user != null && facility != null) {
            listOfRichAttributes.addAll(this.getMemberResourceAttributes(sess, user, facility, attrDef));
        } else if (member != null && group != null) {
            listOfRichAttributes.addAll(this.getMemberResourceAttributes(sess, member, group, attrDef));
        } else if (group != null) {
            listOfRichAttributes.addAll(this.getMemberResourceAttributes(sess, group, attrDef));
        } else if (member != null) {
            listOfRichAttributes.addAll(this.getMemberResourceAttributes(sess, member, attrDef));
        } else if (resource != null) {
            listOfRichAttributes.addAll(this.getMemberResourceAttributes(sess, resource, attrDef));
        } else if (user != null) {
            listOfRichAttributes.addAll(this.getMemberResourceAttributes(sess, user, attrDef));
        } else if (host != null) {
            listOfRichAttributes.addAll(this.getMemberResourceAttributes(sess, host, attrDef));
        } else if (facility != null) {
            listOfRichAttributes.addAll(this.getMemberResourceAttributes(sess, facility, attrDef));
        } else if (vo != null) {
            listOfRichAttributes.addAll(this.getMemberResourceAttributes(sess, vo, attrDef));
        } else if (userExtSource != null) {
            listOfRichAttributes.addAll(this.getMemberResourceAttributes(sess, userExtSource, attrDef));
        } else if (key != null) {
            listOfRichAttributes.addAll(this.getMemberResourceAttributes(sess, attrDef));
        } else {
            throw new InternalErrorException("Unknown combination of PerunBeans: " + aidingAttr);
        }
    } else if (getAttributesManagerImpl().isFromNamespace(attrDef, NS_USER_FACILITY_ATTR)) {
        if (resource != null && member != null) {
            listOfRichAttributes.addAll(this.getUserFacilityAttributes(sess, member, resource, attrDef));
        } else if (group != null && resource != null) {
            listOfRichAttributes.addAll(this.getUserFacilityAttributes(sess, group, resource, attrDef));
        } else if (user != null && facility != null) {
            listOfRichAttributes.addAll(this.getUserFacilityAttributes(sess, user, facility, attrDef));
        } else if (member != null && group != null) {
            listOfRichAttributes.addAll(this.getUserFacilityAttributes(sess, member, group, attrDef));
        } else if (group != null) {
            listOfRichAttributes.addAll(this.getUserFacilityAttributes(sess, group, attrDef));
        } else if (member != null) {
            listOfRichAttributes.addAll(this.getUserFacilityAttributes(sess, member, attrDef));
        } else if (resource != null) {
            listOfRichAttributes.addAll(this.getUserFacilityAttributes(sess, resource, attrDef));
        } else if (user != null) {
            listOfRichAttributes.addAll(this.getUserFacilityAttributes(sess, user, attrDef));
        } else if (host != null) {
            listOfRichAttributes.addAll(this.getUserFacilityAttributes(sess, host, attrDef));
        } else if (facility != null) {
            listOfRichAttributes.addAll(this.getUserFacilityAttributes(sess, facility, attrDef));
        } else if (vo != null) {
            listOfRichAttributes.addAll(this.getUserFacilityAttributes(sess, vo, attrDef));
        } else if (userExtSource != null) {
            listOfRichAttributes.addAll(this.getUserFacilityAttributes(sess, userExtSource, attrDef));
        } else if (key != null) {
            listOfRichAttributes.addAll(this.getUserFacilityAttributes(sess, attrDef));
        } else {
            throw new InternalErrorException("Unknown combination of PerunBeans: " + aidingAttr);
        }
    } else if (getAttributesManagerImpl().isFromNamespace(attrDef, NS_UES_ATTR)) {
        if (resource != null && member != null) {
            // we do not need to use the resource object here
            listOfRichAttributes.addAll(this.getUserExtSourceAttributes(sess, member, attrDef));
        } else if (group != null && resource != null) {
            // we do not need to use the resource object here
            listOfRichAttributes.addAll(this.getUserExtSourceAttributes(sess, group, attrDef));
        } else if (user != null && facility != null) {
            listOfRichAttributes.addAll(this.getUserExtSourceAttributes(sess, user, facility, attrDef));
        } else if (member != null && group != null) {
            // we do not need to use the group object here
            listOfRichAttributes.addAll(this.getUserExtSourceAttributes(sess, member, attrDef));
        } else if (group != null) {
            listOfRichAttributes.addAll(this.getUserExtSourceAttributes(sess, group, attrDef));
        } else if (member != null) {
            listOfRichAttributes.addAll(this.getUserExtSourceAttributes(sess, member, attrDef));
        } else if (resource != null) {
            listOfRichAttributes.addAll(this.getUserExtSourceAttributes(sess, resource, attrDef));
        } else if (user != null) {
            listOfRichAttributes.addAll(this.getUserExtSourceAttributes(sess, user, attrDef));
        } else if (host != null) {
            listOfRichAttributes.addAll(this.getUserExtSourceAttributes(sess, host, attrDef));
        } else if (facility != null) {
            listOfRichAttributes.addAll(this.getUserExtSourceAttributes(sess, facility, attrDef));
        } else if (vo != null) {
            listOfRichAttributes.addAll(this.getUserExtSourceAttributes(sess, vo, attrDef));
        } else if (userExtSource != null) {
            listOfRichAttributes.addAll(this.getUserExtSourceAttributes(sess, userExtSource, attrDef));
        } else if (key != null) {
            listOfRichAttributes.addAll(this.getUserExtSourceAttributes(sess, attrDef));
        } else {
            throw new InternalErrorException("Unknown combination of PerunBeans: " + aidingAttr);
        }
    } else if (getAttributesManagerImpl().isFromNamespace(attrDef, AttributesManager.NS_ENTITYLESS_ATTR)) {
        if (key != null) {
            listOfRichAttributes.addAll(getEntitylessAttributes(sess, key, attrDef));
        } else {
            listOfRichAttributes.addAll(getEntitylessAttributes(sess, attrDef));
        }
    } else {
        throw new InternalErrorException("There is unrecognized namespace in attribute " + attrDef);
    }
    listOfRichAttributes = new ArrayList<>(new HashSet<>(listOfRichAttributes));
    return listOfRichAttributes;
}
Also used : AllAttributesRemovedForMemberAndGroup(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForMemberAndGroup) AttributeRemovedForGroup(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForGroup) AllAttributesRemovedForGroup(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForGroup) AttributeSetForGroup(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForGroup) Group(cz.metacentrum.perun.core.api.Group) AttributeSetForMemberAndGroup(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForMemberAndGroup) AttributeRemovedForMemberAndGroup(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForMemberAndGroup) User(cz.metacentrum.perun.core.api.User) AllUserFacilityAttributesRemovedForFacilitiesAndUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllUserFacilityAttributesRemovedForFacilitiesAndUser) AttributeRemovedForFacilityAndUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForFacilityAndUser) AttributeSetForUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForUser) AllAttributesRemovedForFacilityAndUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForFacilityAndUser) AttributeSetForFacilityAndUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForFacilityAndUser) AttributeRemovedForUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForUser) AllAttributesRemovedForUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForUser) ArrayList(java.util.ArrayList) AttributeSetForGroupAndResource(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForGroupAndResource) AttributeRemovedForGroupAndResource(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForGroupAndResource) AllAttributesRemovedForResource(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForResource) AttributeRemovedForResource(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForResource) Resource(cz.metacentrum.perun.core.api.Resource) AttributeSetForResource(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForResource) AllAttributesRemovedForGroupAndResource(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForGroupAndResource) AttributeRemovedForHost(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForHost) AttributeSetForHost(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForHost) AllAttributesRemovedForHost(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForHost) Host(cz.metacentrum.perun.core.api.Host) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) AllAttributesRemovedForUserExtSource(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForUserExtSource) Vo(cz.metacentrum.perun.core.api.Vo) AttributeSetForVo(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForVo) AllAttributesRemovedForVo(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForVo) AttributeRemovedForVo(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForVo) AttributeRemovedForFacility(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForFacility) Facility(cz.metacentrum.perun.core.api.Facility) AttributeSetForFacility(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForFacility) AttributeSetForResourceAndMember(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForResourceAndMember) AllAttributesRemovedForResourceAndMember(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForResourceAndMember) Member(cz.metacentrum.perun.core.api.Member) AttributeSetForMember(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForMember) AllAttributesRemovedForMember(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForMember) AttributeRemovedForMember(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForMember) AttributeRemovedForResourceAndMember(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForResourceAndMember) HashSet(java.util.HashSet)

Aggregations

Member (cz.metacentrum.perun.core.api.Member)573 Test (org.junit.Test)369 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)331 RichMember (cz.metacentrum.perun.core.api.RichMember)258 User (cz.metacentrum.perun.core.api.User)238 Group (cz.metacentrum.perun.core.api.Group)183 ArrayList (java.util.ArrayList)153 Vo (cz.metacentrum.perun.core.api.Vo)149 Attribute (cz.metacentrum.perun.core.api.Attribute)137 RichUser (cz.metacentrum.perun.core.api.RichUser)108 Resource (cz.metacentrum.perun.core.api.Resource)93 Facility (cz.metacentrum.perun.core.api.Facility)73 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)69 LinkedHashMap (java.util.LinkedHashMap)66 HashSet (java.util.HashSet)65 UserExtSource (cz.metacentrum.perun.core.api.UserExtSource)56 RichGroup (cz.metacentrum.perun.core.api.RichGroup)52 LocalDate (java.time.LocalDate)52 Candidate (cz.metacentrum.perun.core.api.Candidate)51 HashMap (java.util.HashMap)50