use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerBlImpl method removeAttribute.
@Override
public void removeAttribute(PerunSession sess, UserExtSource ues, AttributeDefinition attribute) throws WrongAttributeAssignmentException, WrongAttributeValueException, WrongReferenceAttributeValueException {
if (removeAttributeWithoutCheck(sess, ues, attribute)) {
checkAttributeSemantics(sess, ues, new Attribute(attribute));
checkAttributeDependencies(sess, new RichAttribute<>(ues, null, new Attribute(attribute)));
}
}
use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerBlImpl method getUserExtSourceAttributes.
// --------------------------------USER-EXT-SOURCE-------------------------------
/**
* Returns all relevant UserExtSource RichAttributes for given user.
* Finds all user's userExtSources and returns theirs rich attributes.
* 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 RichAttribute
*/
private List<RichAttribute> getUserExtSourceAttributes(PerunSession sess, User user, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
List<UserExtSource> userExtSources = getPerunBl().getUsersManagerBl().getUserExtSources(sess, user);
for (UserExtSource userExtSourceElement : userExtSources) {
listOfRichAttributes.addAll(getUserExtSourceAttributes(sess, userExtSourceElement, attrDef));
}
return listOfRichAttributes;
}
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 resource.
* Finds the Vo that the resource is assigned to.
* 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> getVoAttributes(PerunSession sess, Resource resource, AttributeDefinition attrDef) throws VoNotExistsException, AttributeNotExistsException, WrongAttributeAssignmentException {
Vo vo = getPerunBl().getVosManagerBl().getVoById(sess, resource.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 getMemberResourceAttributes.
/**
* Returns all relevant MemberResource RichAttributes for given member.
* That means, returns all MemberResource rich attributes for the given member and those resources that can those
* members 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> getMemberResourceAttributes(PerunSession sess, Member member, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException, MemberResourceMismatchException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
if (getPerunBl().getMembersManagerBl().isMemberAllowed(sess, member)) {
List<Resource> resources = getPerunBl().getResourcesManagerBl().getAllowedResources(sess, member);
for (Resource resourceElement : resources) {
Attribute attribute = getPerunBl().getAttributesManagerBl().getAttribute(sess, member, resourceElement, attrDef.getName());
listOfRichAttributes.add(new RichAttribute<>(resourceElement, member, 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 getHostAttributes.
/**
* Returns all relevant Host RichAttributes for given vo.
* Finds assigned resources to the given vo.
* For each of those resources finds theirs facilities.
* For each of those facilities finds theirs hosts.
* For each of those host returns its rich attributes.
* Each rich attribute is returned only once.
*
* @param sess session
* @param vo virtual organization
* @param attrDef type of attribute that will be returned
* @return List of RichAttribute
*/
private List<RichAttribute> getHostAttributes(PerunSession sess, Vo vo, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
List<Resource> resources = getPerunBl().getResourcesManagerBl().getResources(sess, vo);
for (Resource resourceElement : resources) {
listOfRichAttributes.addAll(getHostAttributes(sess, resourceElement, attrDef));
}
listOfRichAttributes = new ArrayList<>(new HashSet<>(listOfRichAttributes));
return listOfRichAttributes;
}
Aggregations