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;
}
Aggregations