use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerBlImpl method getResourceAttributes.
// --------------------------------RESOURCE------------------------------------
/**
* Returns all relevant Resource RichAttributes for given user.
* Finds members for given user. For each allowed member finds resources the member can access.
* For each of those resources returns theirs rich attribute.
* 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 RichAttributes
*/
private List<RichAttribute> getResourceAttributes(PerunSession sess, User user, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
List<Member> members = getPerunBl().getMembersManagerBl().getMembersByUser(sess, user);
for (Member memberElement : members) {
listOfRichAttributes.addAll(getResourceAttributes(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 getUserAttributes.
/**
* Returns all relevant User RichAttributes for given member.
* Finds all members for given group. For each allowed member gets its user. Returns attributes for those users.
* Each rich attribute is returned only once.
*
* @param sess session
* @param group group
* @param attrDef type of attribute that will be returned
* @return List of RichAttributes
*/
private List<RichAttribute> getUserAttributes(PerunSession sess, Group group, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
List<Member> members = getPerunBl().getGroupsManagerBl().getGroupMembers(sess, group);
for (Member memberElement : members) {
listOfRichAttributes.addAll(getUserAttributes(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 removeAttribute.
@Override
public void removeAttribute(PerunSession sess, Member member, Resource resource, AttributeDefinition attribute) throws WrongAttributeAssignmentException, WrongAttributeValueException, WrongReferenceAttributeValueException, MemberResourceMismatchException {
if (removeAttributeWithoutCheck(sess, member, resource, attribute)) {
checkAttributeSemantics(sess, member, resource, new Attribute(attribute));
checkAttributeDependencies(sess, new RichAttribute<>(resource, member, new Attribute(attribute)));
}
}
use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerBlImpl method getUserFacilityAttributes.
/**
* Returns all relevant UserFacility RichAttributes for given host.
* That means, returns all UserFacility rich attributes for the given host's facility and users that can access it.
* 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 RichAttribute
*/
private List<RichAttribute> getUserFacilityAttributes(PerunSession sess, Host host, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
Facility facility = getPerunBl().getFacilitiesManagerBl().getFacilityForHost(sess, host);
List<RichAttribute> listOfRichAttributes = new ArrayList<>(getUserFacilityAttributes(sess, facility, attrDef));
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 user and facility.
* That means, returns all MemberResource rich attributes for the given user's members who are allowed and for
* resources that can those members access and are located on the given facility.
* Each rich attribute is returned only once.
*
* @param sess session
* @param user user
* @param facility facility
* @param attrDef type of attribute that will be returned
* @return List of RichAttribute
*/
private List<RichAttribute> getMemberResourceAttributes(PerunSession sess, User user, Facility facility, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException, MemberResourceMismatchException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
List<Member> membersFromUser = getPerunBl().getMembersManagerBl().getMembersByUser(sess, user);
List<Member> membersFromFacility = getPerunBl().getFacilitiesManagerBl().getAllowedMembers(sess, facility);
membersFromUser.retainAll(membersFromFacility);
List<Resource> resourcesFromFacility = getPerunBl().getFacilitiesManagerBl().getAssignedResources(sess, facility);
List<Resource> resourcesFromUser = getPerunBl().getUsersManagerBl().getAllowedResources(sess, user);
resourcesFromUser.retainAll(resourcesFromFacility);
resourcesFromUser = new ArrayList<>(new HashSet<>(resourcesFromUser));
for (Resource resourceElement : resourcesFromUser) {
List<Member> membersForResourceElement = getPerunBl().getResourcesManagerBl().getAllowedMembers(sess, resourceElement);
membersForResourceElement.retainAll(membersFromUser);
membersForResourceElement = new ArrayList<>(new HashSet<>(membersForResourceElement));
for (Member memberElement : membersForResourceElement) {
Attribute attribute = getPerunBl().getAttributesManagerBl().getAttribute(sess, memberElement, resourceElement, attrDef.getName());
listOfRichAttributes.add(new RichAttribute<>(resourceElement, memberElement, attribute));
}
}
listOfRichAttributes = new ArrayList<>(new HashSet<>(listOfRichAttributes));
return listOfRichAttributes;
}
Aggregations