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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations