Search in sources :

Example 16 with ApplicationFormItemData

use of cz.metacentrum.perun.registrar.model.ApplicationFormItemData in project perun by CESNET.

the class ConsolidatorManagerImpl method checkForSimilarUsers.

@Override
public List<Identity> checkForSimilarUsers(PerunSession sess, List<ApplicationFormItemData> formItems) throws PerunException {
    if (sess.getPerunPrincipal().getUser() != null || formItems == null) {
        return new ArrayList<Identity>();
    }
    Set<RichUser> res = new HashSet<RichUser>();
    List<String> attrNames = new ArrayList<String>();
    attrNames.add("urn:perun:user:attribute-def:def:preferredMail");
    attrNames.add("urn:perun:user:attribute-def:def:organization");
    for (ApplicationFormItemData item : formItems) {
        String value = item.getValue();
        if (item.getFormItem().getType().equals(ApplicationFormItem.Type.VALIDATED_EMAIL)) {
            // search by email
            if (value != null && !value.isEmpty())
                res.addAll(perun.getUsersManager().findRichUsersWithAttributesByExactMatch(registrarSession, value, attrNames));
        }
        if (Objects.equals(item.getFormItem().getPerunDestinationAttribute(), "urn:perun:user:attribute-def:core:displayName")) {
            // search by name
            if (value != null && !value.isEmpty())
                res.addAll(perun.getUsersManager().findRichUsersWithAttributesByExactMatch(registrarSession, value, attrNames));
        }
    }
    return convertToIdentities(new ArrayList<RichUser>(res));
}
Also used : ApplicationFormItemData(cz.metacentrum.perun.registrar.model.ApplicationFormItemData)

Aggregations

ApplicationFormItemData (cz.metacentrum.perun.registrar.model.ApplicationFormItemData)16 EmptyResultDataAccessException (org.springframework.dao.EmptyResultDataAccessException)7 SQLException (java.sql.SQLException)6 DuplicateKeyException (org.springframework.dao.DuplicateKeyException)6 ApplicationFormItem (cz.metacentrum.perun.registrar.model.ApplicationFormItem)5 RegistrarException (cz.metacentrum.perun.registrar.exceptions.RegistrarException)4 MailException (org.springframework.mail.MailException)4 CantBeApprovedException (cz.metacentrum.perun.registrar.exceptions.CantBeApprovedException)3 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)2 Application (cz.metacentrum.perun.registrar.model.Application)2 MailType (cz.metacentrum.perun.registrar.model.ApplicationMail.MailType)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 AlreadyMemberException (cz.metacentrum.perun.core.api.exceptions.AlreadyMemberException)1 ExtSourceNotExistsException (cz.metacentrum.perun.core.api.exceptions.ExtSourceNotExistsException)1 GroupNotExistsException (cz.metacentrum.perun.core.api.exceptions.GroupNotExistsException)1 PerunException (cz.metacentrum.perun.core.api.exceptions.PerunException)1 PrivilegeException (cz.metacentrum.perun.core.api.exceptions.PrivilegeException)1 RegistrarModule (cz.metacentrum.perun.registrar.RegistrarModule)1 AppType (cz.metacentrum.perun.registrar.model.Application.AppType)1