Search in sources :

Example 1 with AllAttributesRemovedForFacilityAndUser

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));
    }
}
Also used : ConsistencyErrorException(cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException) Attribute(cz.metacentrum.perun.core.api.Attribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) WrongAttributeAssignmentException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException) AllAttributesRemovedForFacilityAndUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForFacilityAndUser)

Aggregations

AllAttributesRemovedForFacilityAndUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForFacilityAndUser)1 Attribute (cz.metacentrum.perun.core.api.Attribute)1 RichAttribute (cz.metacentrum.perun.core.api.RichAttribute)1 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)1 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)1