Search in sources :

Example 61 with RichAttribute

use of cz.metacentrum.perun.core.api.RichAttribute 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;
}
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)

Example 62 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 host.
 * Finds the facility the given host is assigned to.
 * For this facility returns its rich attribute.
 * Each rich attribute is returned only once.
 *
 * @param sess    session
 * @param host    host
 * @param attrDef type of attribute that will be returned
 * @return List of RichAttributes
 */
private List<RichAttribute> getFacilityAttributes(PerunSession sess, Host host, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
    Facility facility = getPerunBl().getFacilitiesManagerBl().getFacilityForHost(sess, host);
    List<RichAttribute> listOfRichAttributes = new ArrayList<>(getFacilityAttributes(sess, facility, 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 63 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 resource.
 * Finds facility that the resource belongs to and return its rich attribute.
 * 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 RichAttributes
 */
private List<RichAttribute> getFacilityAttributes(PerunSession sess, Resource resource, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
    Facility facility = getPerunBl().getResourcesManagerBl().getFacility(sess, resource);
    List<RichAttribute> listOfRichAttributes = new ArrayList<>(getFacilityAttributes(sess, facility, 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 64 with RichAttribute

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

the class AttributesManagerBlImpl method getVoAttributes.

/**
 * Returns all Vo RichAttributes.
 * Finds attributes for all Vos.
 * 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> getVoAttributes(PerunSession sess, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
    List<RichAttribute> listOfRichAttributes = new ArrayList<>();
    List<Vo> vos = getPerunBl().getVosManagerBl().getVos(sess);
    for (Vo voElement : vos) {
        Attribute attribute = getPerunBl().getAttributesManagerBl().getAttribute(sess, voElement, attrDef.getName());
        listOfRichAttributes.add(new RichAttribute<>(voElement, null, attribute));
    }
    listOfRichAttributes = new ArrayList<>(new HashSet<>(listOfRichAttributes));
    return listOfRichAttributes;
}
Also used : 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) 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 65 with RichAttribute

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

the class AttributesManagerBlImpl method getMemberResourceAttributes.

/**
 * Returns all relevant MemberResource RichAttributes for given vo.
 * That means, returns all MemberResource rich attributes for resources that belongs to the given vo and for members
 * that can access those resource and are allowed.
 * Each rich attribute is returned only once.
 *
 * @param sess    session
 * @param vo      vo
 * @param attrDef type of attribute that will be returned
 * @return List of RichAttribute
 */
private List<RichAttribute> getMemberResourceAttributes(PerunSession sess, Vo vo, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException, MemberResourceMismatchException {
    List<RichAttribute> listOfRichAttributes = new ArrayList<>();
    List<Resource> resources = getPerunBl().getResourcesManagerBl().getResources(sess, vo);
    for (Resource resourceElement : resources) {
        listOfRichAttributes.addAll(getMemberResourceAttributes(sess, resourceElement, attrDef));
    }
    listOfRichAttributes = new ArrayList<>(new HashSet<>(listOfRichAttributes));
    return listOfRichAttributes;
}
Also used : 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)

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