use of org.activiti.engine.impl.persistence.entity.UserEntity in project Activiti by Activiti.
the class LDAPUserManager method findUserByQueryCriteria.
@Override
public List<User> findUserByQueryCriteria(final UserQueryImpl query, final Page page) {
if (query.getId() != null) {
List<User> result = new ArrayList<User>();
result.add(findUserById(query.getId()));
return result;
} else if (query.getFullNameLike() != null) {
final String fullNameLike = query.getFullNameLike().replaceAll("%", "");
LDAPTemplate ldapTemplate = new LDAPTemplate(ldapConfigurator);
return ldapTemplate.execute(new LDAPCallBack<List<User>>() {
public List<User> executeInContext(InitialDirContext initialDirContext) {
List<User> result = new ArrayList<User>();
try {
String searchExpression = ldapConfigurator.getLdapQueryBuilder().buildQueryByFullNameLike(ldapConfigurator, fullNameLike);
String baseDn = ldapConfigurator.getUserBaseDn() != null ? ldapConfigurator.getUserBaseDn() : ldapConfigurator.getBaseDn();
NamingEnumeration<?> namingEnum = initialDirContext.search(baseDn, searchExpression, createSearchControls());
while (namingEnum.hasMore()) {
SearchResult searchResult = (SearchResult) namingEnum.next();
UserEntity user = new UserEntity();
mapSearchResultToUser(searchResult, user);
result.add(user);
}
namingEnum.close();
} catch (NamingException ne) {
logger.debug("Could not execute LDAP query: " + ne.getMessage(), ne);
return null;
}
return result;
}
});
} else {
throw new ActivitiIllegalArgumentException("Query is currently not supported by LDAPUserManager.");
}
}
Aggregations