Search in sources :

Example 1 with AllAttributesRemovedForResource

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

the class AttributesManagerBlImpl method removeAllAttributes.

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

Aggregations

AllAttributesRemovedForResource (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForResource)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 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)1 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)1 WrongReferenceAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)1