Search in sources :

Example 1 with AllAttributesRemovedForGroupAndResource

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

the class AttributesManagerBlImpl method removeAllAttributes.

@Override
public void removeAllAttributes(PerunSession sess, Resource resource, Group group) throws WrongAttributeValueException, GroupResourceMismatchException, WrongReferenceAttributeValueException {
    this.checkGroupIsFromTheSameVoLikeResource(sess, group, resource);
    List<Attribute> attributes = getAttributes(sess, resource, group);
    if (getAttributesManagerImpl().removeAllAttributes(sess, resource, group)) {
        getPerunBl().getAuditer().log(sess, new AllAttributesRemovedForGroupAndResource(group, resource));
    }
    log.info("{} removed all attributes from group {} on resource {}.", sess.getLogId(), group.getId(), resource.getId());
    for (Attribute attribute : attributes) attribute.setValue(null);
    try {
        checkAttributesSemantics(sess, resource, group, attributes);
        checkAttributesDependencies(sess, resource, group, attributes);
    } catch (WrongAttributeAssignmentException ex) {
        throw new ConsistencyErrorException(ex);
    }
    for (Attribute attribute : attributes) {
        getAttributesManagerImpl().changedAttributeHook(sess, resource, group, 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) AllAttributesRemovedForGroupAndResource(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForGroupAndResource)

Aggregations

AllAttributesRemovedForGroupAndResource (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForGroupAndResource)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