Search in sources :

Example 1 with ImportPerson

use of org.gluu.config.oxtrust.ImportPerson in project oxTrust by GluuFederation.

the class ImportPersonConfiguration method prepareAttributes.

private List<GluuAttribute> prepareAttributes() throws Exception {
    List<GluuAttribute> result = new ArrayList<GluuAttribute>();
    List<ImportPerson> mappings = configurationFactory.getImportPersonConfig().getMappings();
    Iterator<ImportPerson> it = mappings.iterator();
    while (it.hasNext()) {
        ImportPerson importPerson = (ImportPerson) it.next();
        String attributeName = importPerson.getLdapName();
        boolean required = importPerson.getRequired();
        if (StringHelper.isNotEmpty(attributeName)) {
            GluuAttribute attr = null;
            try {
                attr = attributeService.getAttributeByName(attributeName);
            } catch (EntryPersistenceException ex) {
                log.error("Failed to load attribute '{}' definition from LDAP", attributeName, ex);
            }
            if (attr == null) {
                log.warn("Failed to find attribute '{}' definition in LDAP", attributeName);
                attr = createAttributeFromConfig(importPerson);
                if (attr == null) {
                    log.error("Failed to find attribute '{}' definition in '{}'", attributeName, GLUU_IMPORT_PERSON_PROPERTIES_FILE);
                    continue;
                }
            } else {
                attr.setRequred(required);
            }
            result.add(attr);
        }
    // }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) EntryPersistenceException(org.gluu.persist.exception.EntryPersistenceException) ImportPerson(org.gluu.config.oxtrust.ImportPerson) GluuAttribute(org.gluu.model.GluuAttribute)

Aggregations

ArrayList (java.util.ArrayList)1 ImportPerson (org.gluu.config.oxtrust.ImportPerson)1 GluuAttribute (org.gluu.model.GluuAttribute)1 EntryPersistenceException (org.gluu.persist.exception.EntryPersistenceException)1