Search in sources :

Example 1 with AttributeChangedForResourceAndMember

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

the class urn_perun_member_resource_attribute_def_virt_isBanned method resolveBanChangedForResource.

private List<AuditEvent> resolveBanChangedForResource(PerunSessionImpl perunSession, int memberId, int resourceId) throws AttributeNotExistsException {
    List<AuditEvent> resolvingMessages = new ArrayList<>();
    try {
        Member member = perunSession.getPerunBl().getMembersManagerBl().getMemberById(perunSession, memberId);
        Resource resource = perunSession.getPerunBl().getResourcesManagerBl().getResourceById(perunSession, resourceId);
        AttributeDefinition attributeDefinition = perunSession.getPerunBl().getAttributesManagerBl().getAttributeDefinition(perunSession, A_MR_V_isBanned);
        resolvingMessages.add(new AttributeChangedForResourceAndMember(new Attribute(attributeDefinition), resource, member));
    } catch (MemberNotExistsException | ResourceNotExistsException e) {
        log.error("Can't resolve virtual attribute value change for " + this.getClass().getSimpleName() + " module because of exception.", e);
    }
    return resolvingMessages;
}
Also used : AttributeChangedForResourceAndMember(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeChangedForResourceAndMember) MemberNotExistsException(cz.metacentrum.perun.core.api.exceptions.MemberNotExistsException) Attribute(cz.metacentrum.perun.core.api.Attribute) 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) AuditEvent(cz.metacentrum.perun.audit.events.AuditEvent) ResourceNotExistsException(cz.metacentrum.perun.core.api.exceptions.ResourceNotExistsException) AttributeChangedForResourceAndMember(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeChangedForResourceAndMember) Member(cz.metacentrum.perun.core.api.Member)

Example 2 with AttributeChangedForResourceAndMember

use of cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeChangedForResourceAndMember 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)

Aggregations

AttributeChangedForResourceAndMember (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeChangedForResourceAndMember)2 AuditEvent (cz.metacentrum.perun.audit.events.AuditEvent)2 BanRemovedForResource (cz.metacentrum.perun.audit.events.ResourceManagerEvents.BanRemovedForResource)2 BanSetForResource (cz.metacentrum.perun.audit.events.ResourceManagerEvents.BanSetForResource)2 BanUpdatedForResource (cz.metacentrum.perun.audit.events.ResourceManagerEvents.BanUpdatedForResource)2 Attribute (cz.metacentrum.perun.core.api.Attribute)2 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)2 Member (cz.metacentrum.perun.core.api.Member)2 Resource (cz.metacentrum.perun.core.api.Resource)2 ArrayList (java.util.ArrayList)2 BanRemovedForFacility (cz.metacentrum.perun.audit.events.FacilityManagerEvents.BanRemovedForFacility)1 BanSetForFacility (cz.metacentrum.perun.audit.events.FacilityManagerEvents.BanSetForFacility)1 BanUpdatedForFacility (cz.metacentrum.perun.audit.events.FacilityManagerEvents.BanUpdatedForFacility)1 Facility (cz.metacentrum.perun.core.api.Facility)1 Pair (cz.metacentrum.perun.core.api.Pair)1 User (cz.metacentrum.perun.core.api.User)1 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)1 FacilityNotExistsException (cz.metacentrum.perun.core.api.exceptions.FacilityNotExistsException)1 MemberNotExistsException (cz.metacentrum.perun.core.api.exceptions.MemberNotExistsException)1 ResourceNotExistsException (cz.metacentrum.perun.core.api.exceptions.ResourceNotExistsException)1