Search in sources :

Example 1 with PerunVirtualAttribute

use of cz.metacentrum.perun.ldapc.model.PerunVirtualAttribute in project perun by CESNET.

the class VirtualAttributeEventProcessor method processGroupAttributeChange.

public void processGroupAttributeChange(String msg, MessageBeans beans) {
    // ensure we have the correct beans available
    if (beans.getAttribute() == null || beans.getGroup() == null) {
        return;
    }
    try {
        PerunBl perun = (PerunBl) ldapcManager.getPerunBl();
        /* get list of dependent attributes */
        Collection<PerunVirtualAttribute<User>> attrDefs = dependencyManager.getAttributeDependants(beans.getAttribute().getName());
        log.debug("Processing group {} attribute {} change, affected attributes {}", beans.getGroup(), beans.getAttribute(), attrDefs);
        if (attrDefs != null) {
            /* for each concerned user */
            for (User user : perun.getGroupsManagerBl().getGroupUsers(ldapcManager.getPerunSession(), beans.getGroup())) {
                /* get attribute value for each dependent attribute */
                Collection<Pair<PerunAttribute<User>, AttributeDefinition>> userAttrs = this.getAttributeValues(perun, user, attrDefs);
                log.debug("Modifying user {} entry with the new values {}", user.getId(), userAttrs);
                perunUser.modifyEntry(user, userAttrs);
            }
        }
    } catch (InternalErrorException e) {
        log.error("Error processing group {} attribute {} change: {}", beans.getGroup(), beans.getAttribute(), e.getMessage());
    }
}
Also used : User(cz.metacentrum.perun.core.api.User) PerunVirtualAttribute(cz.metacentrum.perun.ldapc.model.PerunVirtualAttribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) Pair(cz.metacentrum.perun.core.api.Pair)

Example 2 with PerunVirtualAttribute

use of cz.metacentrum.perun.ldapc.model.PerunVirtualAttribute in project perun by CESNET.

the class VirtualAttributeEventProcessor method processGroupAttributeRemoval.

public void processGroupAttributeRemoval(String msg, MessageBeans beans) {
    // ensure we have the correct beans available
    if (beans.getGroup() == null || beans.getAttributeDef() == null) {
        return;
    }
    try {
        PerunBl perun = (PerunBl) ldapcManager.getPerunBl();
        Collection<PerunVirtualAttribute<User>> attrDefs = dependencyManager.getAttributeDependants(beans.getAttributeDef().getName());
        log.debug("Processing group {} attribute {} removal, affected attributes {}", beans.getGroup(), beans.getAttributeDef(), attrDefs);
        if (attrDefs != null) {
            for (User user : perun.getGroupsManagerBl().getGroupUsers(ldapcManager.getPerunSession(), beans.getGroup())) {
                /* get attribute value for each dependent attribute */
                Collection<Pair<PerunAttribute<User>, AttributeDefinition>> userAttrs = this.getAttributeValues(perun, user, attrDefs);
                log.debug("Modifying user {} entry with the new values {}", user.getId(), userAttrs);
                perunUser.modifyEntry(user, userAttrs);
            }
        }
    } catch (InternalErrorException e) {
        log.error("Error processing group {} attribute {} removal: {}", beans.getGroup(), beans.getAttributeDef(), e.getMessage());
    }
}
Also used : User(cz.metacentrum.perun.core.api.User) PerunVirtualAttribute(cz.metacentrum.perun.ldapc.model.PerunVirtualAttribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) Pair(cz.metacentrum.perun.core.api.Pair)

Example 3 with PerunVirtualAttribute

use of cz.metacentrum.perun.ldapc.model.PerunVirtualAttribute in project perun by CESNET.

the class VirtualAttributeEventProcessor method processMemberChange.

public void processMemberChange(String msg, MessageBeans beans) {
    // ensure we have the correct beans available
    if (beans.getMember() == null) {
        return;
    }
    try {
        PerunBl perun = (PerunBl) ldapcManager.getPerunBl();
        User user = perun.getUsersManagerBl().getUserByMember(ldapcManager.getPerunSession(), beans.getMember());
        Collection<PerunVirtualAttribute<User>> attrDefs = dependencyManager.getAllAttributeDependants();
        log.debug("Processing member {} status change with attributes {}", user, attrDefs);
        Collection<Pair<PerunAttribute<User>, AttributeDefinition>> userAttrs = this.getAttributeValues(perun, user, attrDefs);
        log.debug("Modifying user {} entry with the new values {}", user.getId(), userAttrs);
        perunUser.modifyEntry(user, userAttrs);
    } catch (InternalErrorException e) {
        log.error("Error processing member {} status change: {}", beans.getMember(), e.getMessage());
    }
}
Also used : User(cz.metacentrum.perun.core.api.User) PerunVirtualAttribute(cz.metacentrum.perun.ldapc.model.PerunVirtualAttribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) Pair(cz.metacentrum.perun.core.api.Pair)

Example 4 with PerunVirtualAttribute

use of cz.metacentrum.perun.ldapc.model.PerunVirtualAttribute in project perun by CESNET.

the class VirtualAttributeEventProcessor method processGroupMemberChange.

public void processGroupMemberChange(String msg, MessageBeans beans) {
    // ensure we have the correct beans available
    if (beans.getMember() == null || beans.getGroup() == null) {
        return;
    }
    try {
        PerunBl perun = (PerunBl) ldapcManager.getPerunBl();
        User user = perun.getUsersManagerBl().getUserByMember(ldapcManager.getPerunSession(), beans.getMember());
        List<String> registeredAttrs = dependencyManager.getRegisteredAttributes();
        List<Attribute> groupAttrs = perun.getAttributesManagerBl().getAttributes(ldapcManager.getPerunSession(), beans.getGroup(), registeredAttrs);
        log.debug("Processing member {} status change in group {} with attributes {}", user, beans.getGroup(), groupAttrs);
        if (!groupAttrs.isEmpty()) {
            List<PerunVirtualAttribute<User>> attrDefs = new ArrayList<>();
            groupAttrs.forEach(attr -> attrDefs.addAll(dependencyManager.getAttributeDependants(attr.getName())));
            log.debug("Found attributes: {}", attrDefs);
            Collection<Pair<PerunAttribute<User>, AttributeDefinition>> userAttrs = this.getAttributeValues(perun, user, attrDefs);
            log.debug("Modifying user {} entry with the new values {}", user.getId(), userAttrs);
            perunUser.modifyEntry(user, userAttrs);
        }
    } catch (InternalErrorException e) {
        log.error("Error processing member {} change in group {}: {}", beans.getMember(), beans.getGroup(), e.getMessage());
    }
}
Also used : User(cz.metacentrum.perun.core.api.User) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunAttribute(cz.metacentrum.perun.ldapc.model.PerunAttribute) PerunVirtualAttribute(cz.metacentrum.perun.ldapc.model.PerunVirtualAttribute) PerunVirtualAttribute(cz.metacentrum.perun.ldapc.model.PerunVirtualAttribute) ArrayList(java.util.ArrayList) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) Pair(cz.metacentrum.perun.core.api.Pair)

Example 5 with PerunVirtualAttribute

use of cz.metacentrum.perun.ldapc.model.PerunVirtualAttribute in project perun by CESNET.

the class VirtualAttributeEventProcessor method processAllGroupAttributesRemoval.

public void processAllGroupAttributesRemoval(String msg, MessageBeans beans) {
    // ensure we have the correct beans available
    if (beans.getGroup() == null) {
        return;
    }
    try {
        PerunBl perun = (PerunBl) ldapcManager.getPerunBl();
        Collection<PerunVirtualAttribute<User>> attrDefs = dependencyManager.getAllAttributeDependants();
        log.debug("Processing group {} all attribute removal, affected attributes {}", beans.getGroup(), attrDefs);
        if (attrDefs != null) {
            for (User user : perun.getGroupsManagerBl().getGroupUsers(ldapcManager.getPerunSession(), beans.getGroup())) {
                /* get attribute value for each dependent attribute */
                Collection<Pair<PerunAttribute<User>, AttributeDefinition>> userAttrs = this.getAttributeValues(perun, user, attrDefs);
                log.debug("Modifying user {} entry with the new values {}", user.getId(), userAttrs);
                perunUser.modifyEntry(user, userAttrs);
            }
        }
    } catch (InternalErrorException e) {
        log.error("Error processing group {} attributes removal: {}", beans.getGroup(), e.getMessage());
    }
}
Also used : User(cz.metacentrum.perun.core.api.User) PerunVirtualAttribute(cz.metacentrum.perun.ldapc.model.PerunVirtualAttribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) Pair(cz.metacentrum.perun.core.api.Pair)

Aggregations

Pair (cz.metacentrum.perun.core.api.Pair)5 User (cz.metacentrum.perun.core.api.User)5 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)5 PerunBl (cz.metacentrum.perun.core.bl.PerunBl)5 PerunVirtualAttribute (cz.metacentrum.perun.ldapc.model.PerunVirtualAttribute)5 Attribute (cz.metacentrum.perun.core.api.Attribute)1 PerunAttribute (cz.metacentrum.perun.ldapc.model.PerunAttribute)1 ArrayList (java.util.ArrayList)1