List of usage examples for javax.naming.ldap SortKey SortKey
public SortKey(String attrID, boolean ascendingOrder, String matchingRuleID)
From source file:de.fiz.ddb.aas.utils.LDAPEngineUtility.java
/** * Converts sort-string to Ldap SortKey[]. sort-string is like cql-sort: * sortfield1/sort.descending sortfield2/sort.ascending * /*from w w w. j ava 2s. co m*/ * @param sort * @return SortKey[] */ public SortKey[] convertSortStringToLdapSortKeys(final Scope scope, final String sort) { if (StringUtils.isBlank(sort) || scope == null) { return null; } String[] sortParts = sort.split("\\s"); List<SortKey> sortKeys = new ArrayList<SortKey>(); for (int i = 0; i < sortParts.length; i++) { if (!StringUtils.isBlank(sortParts[i])) { String[] sortKeyParts = sortParts[i].split("\\/"); boolean ascending = true; if (sortKeyParts.length > 1 && sortKeyParts[1].equals("sort.descending")) { ascending = false; } if (!StringUtils.isBlank(LdapObjectFieldnameMapper.getNameInLdap(sortKeyParts[0], scope))) { SortKey sortKey = new SortKey(LdapObjectFieldnameMapper.getNameInLdap(sortKeyParts[0], scope), ascending, null); sortKeys.add(sortKey); } } } return sortKeys.toArray(new SortKey[0]); }