Search in sources :

Example 1 with AttributeRemovedForResource

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

the class AttributesManagerBlImpl method removeAttributeWithoutCheck.

@Override
public boolean removeAttributeWithoutCheck(PerunSession sess, Resource resource, AttributeDefinition attribute) throws WrongAttributeAssignmentException {
    getAttributesManagerImpl().checkNamespace(sess, attribute, NS_RESOURCE_ATTR);
    if (getAttributesManagerImpl().isCoreAttribute(sess, attribute))
        throw new WrongAttributeAssignmentException(attribute);
    boolean changed;
    try {
        if (this.isVirtAttribute(sess, attribute)) {
            changed = getAttributesManagerImpl().removeVirtualAttribute(sess, resource, attribute);
        } else {
            changed = getAttributesManagerImpl().removeAttribute(sess, resource, attribute);
        }
        if (changed)
            getAttributesManagerImpl().changedAttributeHook(sess, resource, new Attribute(attribute));
    } catch (WrongAttributeValueException | WrongReferenceAttributeValueException ex) {
        throw new InternalErrorException(ex);
    }
    if (changed)
        log.info("{} removed attribute {} from resource {}.", sess.getLogId(), attribute.getName(), resource.getId());
    getPerunBl().getAuditer().log(sess, new AttributeRemovedForResource(new AttributeDefinition(attribute), resource));
    return changed;
}
Also used : AttributeRemovedForResource(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForResource) 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) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) WrongAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)

Aggregations

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