use of cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForUserExtSource in project perun by CESNET.
the class urn_perun_user_attribute_def_virt_eduPersonScopedAffiliationsTest method resolveAttributeValueChangeTest.
@Test
public void resolveAttributeValueChangeTest() throws Exception {
when(session.getPerunBl().getUsersManagerBl().getUserById(session, 1)).thenReturn(user);
AuditEvent event = new AllAttributesRemovedForUserExtSource(ues1);
List<AuditEvent> auditEvents = classInstance.resolveVirtualAttributeValueChange(session, event);
assertEquals(auditEvents.get(0).getClass(), AttributeChangedForUser.class);
event = new AllAttributesRemovedForUser(user);
auditEvents = classInstance.resolveVirtualAttributeValueChange(session, event);
assertEquals(auditEvents.get(0).getClass(), AttributeChangedForUser.class);
Attribute attribute = new Attribute();
attribute.setFriendlyName("eduPersonScopedAffiliationsManuallyAssigned");
event = new AttributeSetForUser(attribute, user);
auditEvents = classInstance.resolveVirtualAttributeValueChange(session, event);
assertEquals(auditEvents.get(0).getClass(), AttributeChangedForUser.class);
when(session.getPerunBl().getAttributesManagerBl().getAttribute(session, user, AttributesManager.NS_USER_ATTR_VIRT + ":" + "eduPersonScopedAffiliations")).thenReturn(attribute);
auditEvents = classInstance.resolveVirtualAttributeValueChange(session, event);
assertEquals(auditEvents.get(0).getClass(), AttributeChangedForUser.class);
}
use of cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForUserExtSource in project perun by CESNET.
the class AttributesManagerBlImpl method removeAllAttributes.
@Override
public void removeAllAttributes(PerunSession sess, UserExtSource ues) throws WrongAttributeValueException, WrongReferenceAttributeValueException {
List<Attribute> attributes = getAttributes(sess, ues);
if (getAttributesManagerImpl().removeAllAttributes(sess, ues)) {
getPerunBl().getAuditer().log(sess, new AllAttributesRemovedForUserExtSource(ues));
}
log.info("{} removed all attributes from user external source {}.", sess.getLogId(), ues.getId());
for (Attribute attribute : attributes) attribute.setValue(null);
try {
checkAttributesSemantics(sess, ues, attributes);
checkAttributesDependencies(sess, ues, attributes);
} catch (WrongAttributeAssignmentException ex) {
throw new ConsistencyErrorException(ex);
}
for (Attribute attribute : attributes) {
getAttributesManagerImpl().changedAttributeHook(sess, ues, new Attribute(attribute));
}
}
Aggregations