Search in sources :

Example 1 with AttributeSetForMemberAndGroup

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

the class AttributesManagerBlImpl method setAttributeWithoutCheck.

@Override
public boolean setAttributeWithoutCheck(PerunSession sess, Member member, Group group, Attribute attribute, boolean workWithUserAttributes) throws WrongAttributeAssignmentException, WrongAttributeValueException, WrongReferenceAttributeValueException, MemberGroupMismatchException {
    this.checkMemberIsFromTheSameVoLikeGroup(sess, member, group);
    if (getAttributesManagerImpl().isCoreAttribute(sess, attribute))
        throw new WrongAttributeAssignmentException(attribute);
    boolean changed;
    if (getAttributesManagerImpl().isFromNamespace(attribute, AttributesManager.NS_MEMBER_GROUP_ATTR)) {
        if (getAttributesManagerImpl().isVirtAttribute(sess, attribute)) {
            changed = getAttributesManagerImpl().setVirtualAttribute(sess, member, group, attribute);
        } else {
            changed = getAttributesManagerImpl().setAttribute(sess, member, group, attribute);
            if (changed) {
                getPerunBl().getAuditer().log(sess, new AttributeSetForMemberAndGroup(attribute, member, group));
                getAttributesManagerImpl().changedAttributeHook(sess, member, group, attribute);
            }
        }
    } else if (workWithUserAttributes) {
        if (getAttributesManagerImpl().isFromNamespace(attribute, AttributesManager.NS_USER_ATTR)) {
            User user = getPerunBl().getUsersManagerBl().getUserByMember(sess, member);
            if (getAttributesManagerImpl().isVirtAttribute(sess, attribute)) {
                changed = getAttributesManagerImpl().setVirtualAttribute(sess, user, attribute);
            } else {
                changed = setAttributeWithoutCheck(sess, user, attribute);
            }
        } else if (getAttributesManagerImpl().isFromNamespace(attribute, AttributesManager.NS_MEMBER_ATTR)) {
            if (getAttributesManagerImpl().isVirtAttribute(sess, attribute)) {
                changed = getAttributesManagerImpl().setVirtualAttribute(sess, member, attribute);
            } else {
                changed = setAttributeWithoutCheck(sess, member, attribute);
            }
        } else {
            throw new WrongAttributeAssignmentException(attribute);
        }
    } else {
        throw new WrongAttributeAssignmentException(attribute);
    }
    return changed;
}
Also used : User(cz.metacentrum.perun.core.api.User) AllUserFacilityAttributesRemovedForFacilitiesAndUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllUserFacilityAttributesRemovedForFacilitiesAndUser) AttributeRemovedForFacilityAndUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForFacilityAndUser) AttributeSetForUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForUser) AllAttributesRemovedForFacilityAndUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForFacilityAndUser) AttributeSetForFacilityAndUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForFacilityAndUser) AttributeRemovedForUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForUser) AllAttributesRemovedForUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForUser) AttributeSetForMemberAndGroup(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForMemberAndGroup) WrongAttributeAssignmentException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)

Aggregations

AllAttributesRemovedForFacilityAndUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForFacilityAndUser)1 AllAttributesRemovedForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForUser)1 AllUserFacilityAttributesRemovedForFacilitiesAndUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllUserFacilityAttributesRemovedForFacilitiesAndUser)1 AttributeRemovedForFacilityAndUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForFacilityAndUser)1 AttributeRemovedForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForUser)1 AttributeSetForFacilityAndUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForFacilityAndUser)1 AttributeSetForMemberAndGroup (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForMemberAndGroup)1 AttributeSetForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForUser)1 User (cz.metacentrum.perun.core.api.User)1 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)1