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 resource.
* For the given resource finds its facility.
* For the facility finds its hosts.
* For each of those host returns its rich attributes.
* Each rich attribute is returned only once.
*
* @param sess session
* @param resource resources
* @param attrDef type of attribute that will be returned
* @return List of RichAttributes
*/
private List<RichAttribute> getHostAttributes(PerunSession sess, Resource resource, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
Facility facility = getPerunBl().getResourcesManagerBl().getFacility(sess, resource);
List<RichAttribute> listOfRichAttributes = new ArrayList<>(getHostAttributes(sess, facility, attrDef));
return listOfRichAttributes;
}
use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerBlImpl method removeAllUserFacilityAttributes.
@Override
public void removeAllUserFacilityAttributes(PerunSession sess, User user) throws WrongAttributeValueException, WrongReferenceAttributeValueException {
List<RichAttribute<User, Facility>> userFacilitiesAttributes = getAttributesManagerImpl().getAllUserFacilityRichAttributes(sess, user);
// remove all non-virtual attributes
if (getAttributesManagerImpl().removeAllUserFacilityAttributes(sess, user)) {
getPerunBl().getAuditer().log(sess, new AllUserFacilityAttributesRemovedForFacilitiesAndUser(user));
}
log.info("{} removed all attributes from user {} on all facilities.", sess.getLogId(), user.getId());
for (RichAttribute<User, Facility> richAttribute : userFacilitiesAttributes) {
try {
checkAttributeSemantics(sess, richAttribute.getSecondaryHolder(), richAttribute.getPrimaryHolder(), new Attribute(richAttribute.getAttribute()));
checkAttributeDependencies(sess, richAttribute);
} catch (WrongAttributeAssignmentException ex) {
throw new ConsistencyErrorException(ex);
}
}
for (RichAttribute<User, Facility> attribute : userFacilitiesAttributes) {
getAttributesManagerImpl().changedAttributeHook(sess, attribute.getSecondaryHolder(), attribute.getPrimaryHolder(), new Attribute(attribute.getAttribute()));
}
}
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 vo.
* Finds resources assigned to given vo.
* For each resource finds facility it belongs to.
* Returns rich attributes for these resources.
* 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 RichAttributes
*/
private List<RichAttribute> getFacilityAttributes(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(getFacilityAttributes(sess, resourceElement, 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 getMemberAttributes.
/**
* Returns all relevant Member RichAttributes for given facility.
* Finds members that can access the given facility. For each allowed member returns its rich attribute.
* Each rich attribute is returned only once.
*
* @param sess session
* @param facility facility
* @param attrDef type of attribute that will be returned
* @return List of RichAttributes
*/
private List<RichAttribute> getMemberAttributes(PerunSession sess, Facility facility, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
List<Member> membersFromFacility = getPerunBl().getFacilitiesManagerBl().getAllowedMembers(sess, facility);
for (Member memberElement : membersFromFacility) {
listOfRichAttributes.addAll(getMemberAttributes(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 getUserExtSourceAttributes.
/**
* Returns all relevant UserExtSource RichAttributes for given userExtSource.
* Each rich attribute is returned only once.
*
* @param sess session
* @param userExtSource userExtSource
* @param attrDef type of attribute that will be returned
* @return List of RichAttribute
*/
private List<RichAttribute> getUserExtSourceAttributes(PerunSession sess, UserExtSource userExtSource, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
Attribute attribute = getPerunBl().getAttributesManagerBl().getAttribute(sess, userExtSource, attrDef.getName());
listOfRichAttributes.add(new RichAttribute<>(userExtSource, null, attribute));
listOfRichAttributes = new ArrayList<>(new HashSet<>(listOfRichAttributes));
return listOfRichAttributes;
}
Aggregations