Search in sources :

Example 1 with UserVirtualAttributesModuleImplApi

use of cz.metacentrum.perun.core.implApi.modules.attributes.UserVirtualAttributesModuleImplApi in project perun by CESNET.

the class UsersManagerBlImpl method getUsersByVirtualAttribute.

private List<User> getUsersByVirtualAttribute(PerunSession sess, AttributeDefinition attributeDef, String attributeValue) {
    // try to find method in attribute module
    UserVirtualAttributesModuleImplApi attributeModule = perunBl.getAttributesManagerBl().getUserVirtualAttributeModule(sess, attributeDef);
    List<User> listOfUsers = attributeModule.searchInAttributesValues((PerunSessionImpl) sess, attributeValue);
    if (listOfUsers != null) {
        return listOfUsers;
    }
    // iterate over all users
    List<User> matchedUsers = new ArrayList<>();
    for (User user : perunBl.getUsersManagerBl().getUsers(sess)) {
        Attribute userAttribute;
        try {
            userAttribute = perunBl.getAttributesManagerBl().getAttribute(sess, user, attributeDef.getName());
        } catch (AttributeNotExistsException | WrongAttributeAssignmentException e) {
            throw new InternalErrorException(e);
        }
        if (userAttribute.valueContains(attributeValue)) {
            matchedUsers.add(user);
        }
    }
    return matchedUsers;
}
Also used : OwnershipRemovedForSpecificUser(cz.metacentrum.perun.audit.events.UserManagerEvents.OwnershipRemovedForSpecificUser) User(cz.metacentrum.perun.core.api.User) OwnershipEnabledForSpecificUser(cz.metacentrum.perun.audit.events.UserManagerEvents.OwnershipEnabledForSpecificUser) UserAddedToOwnersOfSpecificUser(cz.metacentrum.perun.audit.events.UserManagerEvents.UserAddedToOwnersOfSpecificUser) UserExtSourceRemovedFromUser(cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceRemovedFromUser) RichUser(cz.metacentrum.perun.core.api.RichUser) OwnershipDisabledForSpecificUser(cz.metacentrum.perun.audit.events.UserManagerEvents.OwnershipDisabledForSpecificUser) UserExtSourceAddedToUser(cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceAddedToUser) AllUserExtSourcesDeletedForUser(cz.metacentrum.perun.audit.events.UserManagerEvents.AllUserExtSourcesDeletedForUser) Attribute(cz.metacentrum.perun.core.api.Attribute) WrongAttributeAssignmentException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException) UserVirtualAttributesModuleImplApi(cz.metacentrum.perun.core.implApi.modules.attributes.UserVirtualAttributesModuleImplApi) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) ArrayList(java.util.ArrayList) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException)

Aggregations

AllUserExtSourcesDeletedForUser (cz.metacentrum.perun.audit.events.UserManagerEvents.AllUserExtSourcesDeletedForUser)1 OwnershipDisabledForSpecificUser (cz.metacentrum.perun.audit.events.UserManagerEvents.OwnershipDisabledForSpecificUser)1 OwnershipEnabledForSpecificUser (cz.metacentrum.perun.audit.events.UserManagerEvents.OwnershipEnabledForSpecificUser)1 OwnershipRemovedForSpecificUser (cz.metacentrum.perun.audit.events.UserManagerEvents.OwnershipRemovedForSpecificUser)1 UserAddedToOwnersOfSpecificUser (cz.metacentrum.perun.audit.events.UserManagerEvents.UserAddedToOwnersOfSpecificUser)1 UserExtSourceAddedToUser (cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceAddedToUser)1 UserExtSourceRemovedFromUser (cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceRemovedFromUser)1 Attribute (cz.metacentrum.perun.core.api.Attribute)1 RichUser (cz.metacentrum.perun.core.api.RichUser)1 User (cz.metacentrum.perun.core.api.User)1 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)1 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)1 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)1 UserVirtualAttributesModuleImplApi (cz.metacentrum.perun.core.implApi.modules.attributes.UserVirtualAttributesModuleImplApi)1 ArrayList (java.util.ArrayList)1