Search in sources :

Example 1 with AttributeSetForGroupAndResource

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

the class AttributesManagerBlImpl method setAttributeWithoutCheck.

@Override
public boolean setAttributeWithoutCheck(PerunSession sess, Resource resource, Group group, Attribute attribute) throws WrongAttributeAssignmentException, WrongAttributeValueException, WrongReferenceAttributeValueException, GroupResourceMismatchException {
    this.checkGroupIsFromTheSameVoLikeResource(sess, group, resource);
    getAttributesManagerImpl().checkNamespace(sess, attribute, AttributesManager.NS_GROUP_RESOURCE_ATTR);
    if (getAttributesManagerImpl().isCoreAttribute(sess, attribute))
        throw new WrongAttributeAssignmentException(attribute);
    boolean changed;
    if (isVirtAttribute(sess, attribute)) {
        // FIXME Zatim je zakazane nastavovani virtualnich atributu group_resource
        Attribute storedAttribute;
        try {
            storedAttribute = getAttribute(sess, resource, group, attribute.getName());
        } catch (AttributeNotExistsException ex) {
            throw new ConsistencyErrorException(ex);
        }
        if (!(storedAttribute.getValue() == null ? attribute.getValue() == null : storedAttribute.getValue().equals(attribute.getValue()))) {
            // FIXME
            if (attribute.getName().equals(AttributesManager.NS_GROUP_RESOURCE_ATTR_VIRT + ":unixGID") || attribute.getName().equals(AttributesManager.NS_GROUP_RESOURCE_ATTR_VIRT + ":unixGroupName")) {
                return getAttributesManagerImpl().setVirtualAttribute(sess, resource, group, attribute);
            } else {
                throw new InternalErrorException("Virtual attribute can't be set this way yet. Please set physical attribute. " + attribute);
            }
        } else {
            return false;
        }
    } else {
        changed = getAttributesManagerImpl().setAttribute(sess, resource, group, attribute);
    }
    if (changed) {
        getPerunBl().getAuditer().log(sess, new AttributeSetForGroupAndResource(attribute, group, resource));
        getAttributesManagerImpl().changedAttributeHook(sess, resource, group, attribute);
    }
    return changed;
}
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) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) AttributeSetForGroupAndResource(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForGroupAndResource)

Aggregations

AttributeSetForGroupAndResource (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForGroupAndResource)1 Attribute (cz.metacentrum.perun.core.api.Attribute)1 RichAttribute (cz.metacentrum.perun.core.api.RichAttribute)1 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)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