Search in sources :

Example 1 with AllAttributesRemovedForUserExtSource

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);
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) AllAttributesRemovedForUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForUser) AuditEvent(cz.metacentrum.perun.audit.events.AuditEvent) AllAttributesRemovedForUserExtSource(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForUserExtSource) AttributeSetForUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForUser) Test(org.junit.Test)

Example 2 with AllAttributesRemovedForUserExtSource

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));
    }
}
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) AllAttributesRemovedForUserExtSource(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForUserExtSource)

Aggregations

AllAttributesRemovedForUserExtSource (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForUserExtSource)2 Attribute (cz.metacentrum.perun.core.api.Attribute)2 AllAttributesRemovedForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForUser)1 AttributeSetForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForUser)1 AuditEvent (cz.metacentrum.perun.audit.events.AuditEvent)1 RichAttribute (cz.metacentrum.perun.core.api.RichAttribute)1 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)1 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)1 Test (org.junit.Test)1