Search in sources :

Example 1 with AttributeSetForResourceAndMember

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

the class AttributesManagerBlImpl method setAttributeWithoutCheck.

@Override
public boolean setAttributeWithoutCheck(PerunSession sess, Member member, Resource resource, Attribute attribute, boolean workWithUserAttributes) throws WrongAttributeAssignmentException, WrongAttributeValueException, WrongReferenceAttributeValueException, MemberResourceMismatchException {
    this.checkMemberIsFromTheSameVoLikeResource(sess, member, resource);
    if (getAttributesManagerImpl().isCoreAttribute(sess, attribute))
        throw new WrongAttributeAssignmentException(attribute);
    boolean changed;
    if (getAttributesManagerImpl().isFromNamespace(attribute, AttributesManager.NS_MEMBER_RESOURCE_ATTR)) {
        // NS_MEMBER_RESOURCE_ATTR
        if (getAttributesManagerImpl().isVirtAttribute(sess, attribute)) {
            throw new InternalErrorException("Virtual attribute can't be set this way yet. Please set physical attribute instead.");
        } else {
            changed = getAttributesManagerImpl().setAttribute(sess, resource, member, attribute);
            if (changed) {
                getPerunBl().getAuditer().log(sess, new AttributeSetForResourceAndMember(attribute, resource, member));
                getAttributesManagerImpl().changedAttributeHook(sess, member, resource, attribute);
            }
        }
    } else if (workWithUserAttributes) {
        if (getAttributesManagerImpl().isFromNamespace(attribute, AttributesManager.NS_USER_FACILITY_ATTR)) {
            // NS_USER_FACILITY_ATTR
            User user = getPerunBl().getUsersManagerBl().getUserByMember(sess, member);
            Facility facility = getPerunBl().getResourcesManagerBl().getFacility(sess, resource);
            if (getAttributesManagerImpl().isVirtAttribute(sess, attribute)) {
                changed = getAttributesManagerImpl().setVirtualAttribute(sess, facility, user, attribute);
            } else {
                changed = setAttributeWithoutCheck(sess, facility, user, attribute);
            }
        } else if (getAttributesManagerImpl().isFromNamespace(attribute, AttributesManager.NS_USER_ATTR)) {
            // NS_USER_ATTR
            User user = getPerunBl().getUsersManagerBl().getUserByMember(sess, member);
            if (getAttributesManagerImpl().isVirtAttribute(sess, attribute)) {
                throw new InternalErrorException("Virtual attribute can't be set this way yet. Please set physical attribute instead.");
            } 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 : AttributeSetForResourceAndMember(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForResourceAndMember) 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) WrongAttributeAssignmentException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) AttributeRemovedForFacility(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForFacility) Facility(cz.metacentrum.perun.core.api.Facility) AttributeSetForFacility(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForFacility)

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 AttributeRemovedForFacility (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForFacility)1 AttributeRemovedForFacilityAndUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForFacilityAndUser)1 AttributeRemovedForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForUser)1 AttributeSetForFacility (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForFacility)1 AttributeSetForFacilityAndUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForFacilityAndUser)1 AttributeSetForResourceAndMember (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForResourceAndMember)1 AttributeSetForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForUser)1 Facility (cz.metacentrum.perun.core.api.Facility)1 User (cz.metacentrum.perun.core.api.User)1 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)1 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)1