Search in sources :

Example 26 with AuditEvent

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

the class urn_perun_member_resource_attribute_def_virt_isBanned method resolveBanChangedForFacility.

private List<AuditEvent> resolveBanChangedForFacility(PerunSessionImpl perunSession, int userId, int facilityId) {
    List<AuditEvent> resolvingMessages = new ArrayList<>();
    try {
        User user = perunSession.getPerunBl().getUsersManagerBl().getUserById(perunSession, userId);
        Facility facility = perunSession.getPerunBl().getFacilitiesManagerBl().getFacilityById(perunSession, facilityId);
        List<Pair<Resource, Member>> listOfAffectedObjects = getAffectedMemberResourceObjects(perunSession, user, facility);
        for (Pair<Resource, Member> affectedObjects : listOfAffectedObjects) {
            try {
                AttributeDefinition attributeDefinition = perunSession.getPerunBl().getAttributesManagerBl().getAttributeDefinition(perunSession, A_MR_V_isBanned);
                resolvingMessages.add(new AttributeChangedForResourceAndMember(new Attribute(attributeDefinition), affectedObjects.getLeft(), affectedObjects.getRight()));
            } catch (AttributeNotExistsException ex) {
                // This means that attribute isBanned not exists at all so we can skip this process
                log.info("Virtual attribute {} not exists.", this.getClass().getSimpleName());
                break;
            }
        }
    } catch (UserNotExistsException | FacilityNotExistsException e) {
        log.error("Can't resolve virtual attribute value change for " + this.getClass().getSimpleName() + " module because of exception.", e);
    }
    return resolvingMessages;
}
Also used : User(cz.metacentrum.perun.core.api.User) AttributeChangedForResourceAndMember(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeChangedForResourceAndMember) Attribute(cz.metacentrum.perun.core.api.Attribute) UserNotExistsException(cz.metacentrum.perun.core.api.exceptions.UserNotExistsException) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) ArrayList(java.util.ArrayList) Resource(cz.metacentrum.perun.core.api.Resource) BanSetForResource(cz.metacentrum.perun.audit.events.ResourceManagerEvents.BanSetForResource) BanUpdatedForResource(cz.metacentrum.perun.audit.events.ResourceManagerEvents.BanUpdatedForResource) BanRemovedForResource(cz.metacentrum.perun.audit.events.ResourceManagerEvents.BanRemovedForResource) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) FacilityNotExistsException(cz.metacentrum.perun.core.api.exceptions.FacilityNotExistsException) AuditEvent(cz.metacentrum.perun.audit.events.AuditEvent) BanRemovedForFacility(cz.metacentrum.perun.audit.events.FacilityManagerEvents.BanRemovedForFacility) Facility(cz.metacentrum.perun.core.api.Facility) BanUpdatedForFacility(cz.metacentrum.perun.audit.events.FacilityManagerEvents.BanUpdatedForFacility) BanSetForFacility(cz.metacentrum.perun.audit.events.FacilityManagerEvents.BanSetForFacility) AttributeChangedForResourceAndMember(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeChangedForResourceAndMember) Member(cz.metacentrum.perun.core.api.Member) Pair(cz.metacentrum.perun.core.api.Pair)

Example 27 with AuditEvent

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

the class urn_perun_user_attribute_def_virt_tcsMails_muTest method resolveVirtualAttributeValueChangeSet4.

@Test
public void resolveVirtualAttributeValueChangeSet4() throws Exception {
    AuditEvent userSet = new AttributeSetForUser(privateMailsAttr, user);
    List<AuditEvent> msgs = classInstance.resolveVirtualAttributeValueChange(sess, userSet);
    assertTrue("audit should contain change of tcsMails", msgs.get(0).getMessage().contains(expectedTestOfMessage));
}
Also used : AuditEvent(cz.metacentrum.perun.audit.events.AuditEvent) AttributeSetForUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForUser) Test(org.junit.Test)

Example 28 with AuditEvent

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

the class urn_perun_user_attribute_def_virt_tcsMails_muTest method resolveVirtualAttributeValueChangeSet5.

@Test
public void resolveVirtualAttributeValueChangeSet5() throws Exception {
    AuditEvent userSet = new AttributeSetForUser(o365MailsAttr, user);
    List<AuditEvent> msgs = classInstance.resolveVirtualAttributeValueChange(sess, userSet);
    assertTrue("audit should contain change of tcsMails", msgs.get(0).getMessage().contains(expectedTestOfMessage));
}
Also used : AuditEvent(cz.metacentrum.perun.audit.events.AuditEvent) AttributeSetForUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForUser) Test(org.junit.Test)

Example 29 with AuditEvent

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

the class urn_perun_user_attribute_def_virt_tcsMails_muTest method resolveVirtualAttributeValueChangeRemovedAll.

@Test
public void resolveVirtualAttributeValueChangeRemovedAll() throws Exception {
    AuditEvent allRemForUser = new AllAttributesRemovedForUser(user);
    List<AuditEvent> msgs = classInstance.resolveVirtualAttributeValueChange(sess, allRemForUser);
    assertTrue("audit should contain change of tcsMails", msgs.get(0).getMessage().contains(expectedTestOfMessage));
}
Also used : AllAttributesRemovedForUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForUser) AuditEvent(cz.metacentrum.perun.audit.events.AuditEvent) Test(org.junit.Test)

Example 30 with AuditEvent

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

the class urn_perun_user_attribute_def_virt_tcsMails_muTest method resolveVirtualAttributeValueChangeSet2.

@Test
public void resolveVirtualAttributeValueChangeSet2() throws Exception {
    AuditEvent userSet = new AttributeSetForUser(isMailAttr, user);
    List<AuditEvent> msgs = classInstance.resolveVirtualAttributeValueChange(sess, userSet);
    assertTrue("audit should contain change of tcsMails", msgs.get(0).getMessage().contains(expectedTestOfMessage));
}
Also used : AuditEvent(cz.metacentrum.perun.audit.events.AuditEvent) AttributeSetForUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForUser) Test(org.junit.Test)

Aggregations

AuditEvent (cz.metacentrum.perun.audit.events.AuditEvent)33 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)11 Attribute (cz.metacentrum.perun.core.api.Attribute)9 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)9 AttributeSetForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForUser)8 AttributeRemovedForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForUser)7 User (cz.metacentrum.perun.core.api.User)7 AttributeChangedForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeChangedForUser)5 AllAttributesRemovedForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForUser)4 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)4 UserNotExistsException (cz.metacentrum.perun.core.api.exceptions.UserNotExistsException)4 EnrichedSponsorship (cz.metacentrum.perun.core.api.EnrichedSponsorship)3 Facility (cz.metacentrum.perun.core.api.Facility)3 Member (cz.metacentrum.perun.core.api.Member)3 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)3 JsonParseException (com.fasterxml.jackson.core.JsonParseException)2 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)2 AttributeChangedForFacility (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeChangedForFacility)2 AttributeChangedForResourceAndMember (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeChangedForResourceAndMember)2