use of cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForFacilityAndUser in project perun by CESNET.
the class AttributesManagerBlImpl method removeAllAttributes.
@Override
public void removeAllAttributes(PerunSession sess, Facility facility, User user) throws WrongAttributeValueException, WrongReferenceAttributeValueException {
List<Attribute> attributes = getAttributes(sess, facility, user);
// remove all non-virtual attributes
boolean changed = getAttributesManagerImpl().removeAllAttributes(sess, facility, user);
// remove all virtual attributes
List<Attribute> virtualAttributes = getVirtualAttributes(sess, facility, user);
for (Attribute attribute : virtualAttributes) {
changed = getAttributesManagerImpl().removeVirtualAttribute(sess, facility, user, attribute) || changed;
}
attributes.addAll(virtualAttributes);
if (changed) {
getPerunBl().getAuditer().log(sess, new AllAttributesRemovedForFacilityAndUser(facility, user));
}
log.info("{} removed all attributes from user {} on facility {}.", sess.getLogId(), user.getId(), facility.getId());
for (Attribute attribute : attributes) attribute.setValue(null);
try {
checkAttributesSemantics(sess, facility, user, attributes);
checkAttributesDependencies(sess, facility, user, attributes);
} catch (WrongAttributeAssignmentException ex) {
throw new ConsistencyErrorException(ex);
}
for (Attribute attribute : attributes) {
getAttributesManagerImpl().changedAttributeHook(sess, facility, user, new Attribute(attribute));
}
}
Aggregations