Search in sources :

Example 1 with AttributeRemovedForFacilityAndUser

use of cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForFacilityAndUser in project perun by CESNET.

the class AttributesManagerBlImpl method removeAttributeWithoutCheck.

@Override
public boolean removeAttributeWithoutCheck(PerunSession sess, Facility facility, User user, AttributeDefinition attribute) throws WrongAttributeAssignmentException {
    getAttributesManagerImpl().checkNamespace(sess, attribute, NS_USER_FACILITY_ATTR);
    if (getAttributesManagerImpl().isCoreAttribute(sess, attribute))
        throw new WrongAttributeAssignmentException(attribute);
    boolean changed;
    if (getAttributesManagerImpl().isVirtAttribute(sess, attribute)) {
        changed = getAttributesManagerImpl().removeVirtualAttribute(sess, facility, user, attribute);
    } else {
        changed = getAttributesManagerImpl().removeAttribute(sess, facility, user, attribute);
    }
    if (changed) {
        getAttributesManagerImpl().changedAttributeHook(sess, facility, user, new Attribute(attribute));
        log.info("{} removed attribute {} from user {} on facility {}.", sess.getLogId(), attribute.getName(), user.getId(), facility.getId());
        getPerunBl().getAuditer().log(sess, new AttributeRemovedForFacilityAndUser(new AttributeDefinition(attribute), facility, user));
    }
    return changed;
}
Also used : AttributeRemovedForFacilityAndUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForFacilityAndUser) Attribute(cz.metacentrum.perun.core.api.Attribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) WrongAttributeAssignmentException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition)

Aggregations

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