use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerBlImpl method getVoAttributes.
/**
* Returns all relevant Vo RichAttributes for given group.
* Finds directly the Vo where the group belongs.
* 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> getVoAttributes(PerunSession sess, Group group, AttributeDefinition attrDef) throws VoNotExistsException, AttributeNotExistsException, WrongAttributeAssignmentException {
Vo vo = getPerunBl().getVosManagerBl().getVoById(sess, group.getVoId());
List<RichAttribute> listOfRichAttributes = new ArrayList<>(getVoAttributes(sess, vo, attrDef));
return listOfRichAttributes;
}
use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerBlImpl method getGroupAttributes.
/**
* Returns all relevant Group RichAttributes for given member.
* Checks if given member is allowed. If so, finds all groups for it. For each group returns its rich attribute.
* If member is not allowed return an empty List.
* 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 RichAttributes
*/
private List<RichAttribute> getGroupAttributes(PerunSession sess, Member member, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
if (getPerunBl().getMembersManagerBl().isMemberAllowed(sess, member)) {
List<Group> groupsFromMember = getPerunBl().getGroupsManagerBl().getAllMemberGroups(sess, member);
for (Group groupElement : groupsFromMember) {
listOfRichAttributes.addAll(getGroupAttributes(sess, groupElement, 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 getMemberGroupAttributes.
/**
* Returns all relevant MemberGroup RichAttributes for given host.
* That means, returns all MemberGroup rich attributes for groups that can access the given host's facility and
* for members that can access these groups and are allowed.
* 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> getMemberGroupAttributes(PerunSession sess, Host host, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException, MemberGroupMismatchException {
Facility facility = getPerunBl().getFacilitiesManagerBl().getFacilityForHost(sess, host);
List<RichAttribute> listOfRichAttributes = new ArrayList<>(getMemberGroupAttributes(sess, facility, attrDef));
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, String key, AttributeDefinition attribute) throws WrongAttributeValueException, WrongAttributeAssignmentException, WrongReferenceAttributeValueException {
if (removeAttributeWithoutCheck(sess, key, attribute)) {
checkAttributeSemantics(sess, key, new Attribute(attribute));
checkAttributeDependencies(sess, new RichAttribute<>(key, null, new Attribute(attribute)));
}
}
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 resource.
* That means, returns all GroupResource rich attributes for the given resource and those groups that can access
* this resource.
* 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> getGroupResourceAttributes(PerunSession sess, Resource resource, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException, GroupResourceMismatchException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
List<Group> groupsFromResource = getPerunBl().getResourcesManagerBl().getAssignedGroups(sess, resource);
for (Group groupElement : groupsFromResource) {
Attribute attribute = getPerunBl().getAttributesManagerBl().getAttribute(sess, resource, groupElement, attrDef.getName());
listOfRichAttributes.add(new RichAttribute<>(resource, groupElement, attribute));
}
listOfRichAttributes = new ArrayList<>(new HashSet<>(listOfRichAttributes));
return listOfRichAttributes;
}
Aggregations