Search in sources :

Example 66 with RichAttribute

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

the class AttributesManagerBlImpl method getFacilityAttributes.

/**
 * Finds all facilities rich attributes.
 * Each rich attribute is returned only once.
 *
 * @param sess    session
 * @param attrDef type of attribute that will be returned
 * @return List of RichAttribute
 */
private List<RichAttribute> getFacilityAttributes(PerunSession sess, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
    List<RichAttribute> listOfRichAttributes = new ArrayList<>();
    List<Facility> facilities = getPerunBl().getFacilitiesManagerBl().getFacilities(sess);
    for (Facility facilityElement : facilities) {
        listOfRichAttributes.addAll(getFacilityAttributes(sess, facilityElement, attrDef));
    }
    return listOfRichAttributes;
}
Also used : RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) ArrayList(java.util.ArrayList) AttributeRemovedForFacility(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForFacility) Facility(cz.metacentrum.perun.core.api.Facility) AttributeSetForFacility(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForFacility)

Example 67 with RichAttribute

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

the class AttributesManagerBlImpl method getFacilityAttributes.

/**
 * Returns all relevant Facility RichAttributes for given member.
 * 1. Checks if given member is allowed, if not, an empty list is returned.
 * 2. Otherwise finds groups for given member.
 * 3. For those groups finds assigned resources.
 * 4. Finds facility for each resource.
 * 5. Returns rich attributes for those facilities.
 * Each rich attribute is returned only once.
 *
 * @param sess    session
 * @param member  member
 * @param attrDef type of attribute that will be returned
 * @return List of RichAttribute
 */
private List<RichAttribute> getFacilityAttributes(PerunSession sess, Member member, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
    List<RichAttribute> listOfRichAttributes = new ArrayList<>();
    if (getPerunBl().getMembersManagerBl().isMemberAllowed(sess, member)) {
        List<Group> groupsForMember = getPerunBl().getGroupsManagerBl().getAllMemberGroups(sess, member);
        for (Group groupElement : groupsForMember) {
            listOfRichAttributes.addAll(getFacilityAttributes(sess, groupElement, 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) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 68 with RichAttribute

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

the class AttributesManagerBlImpl method getGroupResourceAttributes.

/**
 * Returns all relevant GroupResource RichAttributes for given member.
 * That means, returns all GroupResource rich attributes for those groups that the given member is assigned to
 * and for those resources that the given member can access.
 * If the given member is not allowed, an empty list is returned.
 * Each rich attribute is returned only once.
 *
 * @param sess    session
 * @param member  member
 * @param attrDef type of attribute that will be returned
 * @return List of RichAttribute
 */
private List<RichAttribute> getGroupResourceAttributes(PerunSession sess, Member member, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException, GroupResourceMismatchException {
    List<RichAttribute> listOfRichAttributes = new ArrayList<>();
    if (getPerunBl().getMembersManagerBl().isMemberAllowed(sess, member)) {
        List<Group> groupsFromMember = getPerunBl().getGroupsManagerBl().getAllMemberGroups(sess, member);
        List<Resource> resourcesFromMember = getPerunBl().getResourcesManagerBl().getAllowedResources(sess, member);
        for (Resource resourceElement : resourcesFromMember) {
            List<Group> groupsFromResourceElement = getPerunBl().getResourcesManagerBl().getAssignedGroups(sess, resourceElement);
            groupsFromResourceElement.retainAll(groupsFromMember);
            groupsFromResourceElement = new ArrayList<>(new HashSet<>(groupsFromResourceElement));
            for (Group groupElement : groupsFromResourceElement) {
                Attribute attribute = getPerunBl().getAttributesManagerBl().getAttribute(sess, resourceElement, groupElement, attrDef.getName());
                listOfRichAttributes.add(new RichAttribute<>(resourceElement, groupElement, attribute));
            }
        }
    }
    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) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) Attribute(cz.metacentrum.perun.core.api.Attribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) 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) HashSet(java.util.HashSet)

Example 69 with RichAttribute

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

the class AttributesManagerBlImpl method getResourceAttributes.

/**
 * Finds rich attributes for all resources.
 * Each rich attribute is returned only once.
 *
 * @param sess    session
 * @param attrDef type of attribute that will be returned
 * @return List of RichAttributes
 */
private List<RichAttribute> getResourceAttributes(PerunSession sess, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
    List<RichAttribute> listOfRichAttributes = new ArrayList<>();
    List<Vo> vos = getPerunBl().getVosManagerBl().getVos(sess);
    for (Vo voElement : vos) {
        listOfRichAttributes.addAll(getResourceAttributes(sess, voElement, attrDef));
    }
    listOfRichAttributes = new ArrayList<>(new HashSet<>(listOfRichAttributes));
    return listOfRichAttributes;
}
Also used : RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) ArrayList(java.util.ArrayList) 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) HashSet(java.util.HashSet)

Example 70 with RichAttribute

use of cz.metacentrum.perun.core.api.RichAttribute 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;
}
Also used : RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) ArrayList(java.util.ArrayList) 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

RichAttribute (cz.metacentrum.perun.core.api.RichAttribute)321 ArrayList (java.util.ArrayList)284 Attribute (cz.metacentrum.perun.core.api.Attribute)220 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)154 Test (org.junit.Test)154 Method (java.lang.reflect.Method)140 List (java.util.List)140 HashSet (java.util.HashSet)94 AllAttributesRemovedForMember (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForMember)34 AllAttributesRemovedForResourceAndMember (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForResourceAndMember)34 AttributeRemovedForMember (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForMember)34 AttributeRemovedForResourceAndMember (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForResourceAndMember)34 AttributeSetForMember (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForMember)34 AttributeSetForResourceAndMember (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForResourceAndMember)34 Member (cz.metacentrum.perun.core.api.Member)34 AttributeRemovedForFacility (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForFacility)32 AttributeSetForFacility (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForFacility)32 Facility (cz.metacentrum.perun.core.api.Facility)32 AllAttributesRemovedForFacilityAndUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForFacilityAndUser)31 AllAttributesRemovedForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForUser)31