use of cz.metacentrum.perun.audit.events.ResourceManagerEvents.GroupAssignedToResource in project perun by CESNET.
the class ResourcesManagerBlImpl method processGroupResourceActivation.
/**
* Sets assignment status of given group and resource to ACTIVE. Check if attributes for each member
* from group are valid. Fill members' attributes with missing values.
*
* @param sess session
* @param group group
* @param resource resource
* @throws WrongAttributeValueException when an attribute value has wrong/illegal syntax
* @throws WrongReferenceAttributeValueException when an attribute value has wrong/illegal semantics
* @throws GroupResourceMismatchException when the given group and resource are not from the same VO
* @throws GroupNotDefinedOnResourceException when there is no such group-resource assignment
*/
private void processGroupResourceActivation(PerunSession sess, Group group, Resource resource) throws GroupResourceMismatchException, WrongReferenceAttributeValueException, WrongAttributeValueException, GroupNotDefinedOnResourceException {
getPerunBl().getAttributesManagerBl().checkGroupIsFromTheSameVoLikeResource(sess, group, resource);
// set status as ACTIVE first because methods checkAttributesSemantics and fillAttribute need active state to work correctly
getResourcesManagerImpl().setGroupResourceStatus(sess, group, resource, GroupResourceStatus.ACTIVE);
// reset assignment failure cause
getResourcesManagerImpl().setFailedGroupResourceAssignmentCause(sess, group, resource, null);
// if there are no services, the members are empty and there is nothing more to process
if (getAssignedServices(sess, resource).isEmpty()) {
getPerunBl().getAuditer().log(sess, new GroupAssignedToResource(group, resource));
return;
}
// get/fill/set all required group and group-resource attributes
try {
List<Attribute> attributes = getPerunBl().getAttributesManagerBl().getResourceRequiredAttributes(sess, resource, resource, group, true);
attributes = getPerunBl().getAttributesManagerBl().fillAttributes(sess, resource, group, attributes, true);
getPerunBl().getAttributesManagerBl().setAttributes(sess, resource, group, attributes, true);
} catch (WrongAttributeAssignmentException | GroupResourceMismatchException ex) {
throw new ConsistencyErrorException(ex);
}
List<Member> members = getPerunBl().getGroupsManagerBl().getGroupMembersExceptInvalidAndDisabled(sess, group);
// get all "allowed" group members and get/fill/set required attributes for them
Facility facility = getPerunBl().getResourcesManagerBl().getFacility(sess, resource);
for (Member member : members) {
User user = getPerunBl().getUsersManagerBl().getUserByMember(sess, member);
try {
getPerunBl().getAttributesManagerBl().setRequiredAttributes(sess, facility, resource, user, member, true);
} catch (WrongAttributeAssignmentException | MemberResourceMismatchException | AttributeNotExistsException ex) {
throw new ConsistencyErrorException(ex);
}
}
getPerunBl().getAuditer().log(sess, new GroupAssignedToResource(group, resource));
// TODO: set and check member-group attributes
}
Aggregations