use of com.iplanet.am.sdk.AMSearchResults in project OpenAM by OpenRock.
the class DirectoryManagerImpl method search3.
public Map search3(String token, String entryDN, String searchFilter, List sortKeys, int startIndex, int beforeCount, int afterCount, String jumpTo, int timeOut, int maxResults, int scope, boolean allAttributes, Set attrNamesSet) throws AMRemoteException, SSOException, RemoteException {
// Construct the SortKeys
initialize();
SortKey[] keys = null;
int keysLength = 0;
if (sortKeys != null && (keysLength = sortKeys.size()) != 0) {
keys = new SortKey[keysLength];
for (int i = 0; i < keysLength; i++) {
String data = (String) sortKeys.get(i);
keys[i] = new SortKey();
keys[i].reverse = data.startsWith("true:");
keys[i].attributeName = data.substring(5);
}
}
// Construct SearchControl
SearchControl sc = new SearchControl();
if (keys != null) {
sc.setSortKeys(keys);
}
if (jumpTo == null) {
sc.setVLVRange(startIndex, beforeCount, afterCount);
} else {
sc.setVLVRange(jumpTo, beforeCount, afterCount);
}
sc.setTimeOut(timeOut);
sc.setMaxResults(maxResults);
sc.setSearchScope(scope);
sc.setAllReturnAttributes(allAttributes);
String[] attrNames = new String[attrNamesSet.size()];
attrNames = (String[]) attrNamesSet.toArray(attrNames);
// Perform the search
try {
AMSearchResults results = dsServices.search(tm.createSSOToken(token), entryDN, searchFilter, sc, attrNames);
// Convert results to Map
Map answer = results.getResultAttributes();
if (answer == null) {
answer = new HashMap();
}
answer.put(com.iplanet.am.sdk.remote.RemoteServicesImpl.AMSR_COUNT, Integer.toString(results.getTotalResultCount()));
answer.put(com.iplanet.am.sdk.remote.RemoteServicesImpl.AMSR_RESULTS, results.getSearchResults());
answer.put(com.iplanet.am.sdk.remote.RemoteServicesImpl.AMSR_CODE, Integer.toString(results.getErrorCode()));
return (answer);
} catch (AMException amex) {
if (debug.messageEnabled()) {
debug.message("DMI::search(with SearchControl3): entryDN=" + entryDN + "the exception is: " + amex);
}
throw convertException(amex);
}
}
use of com.iplanet.am.sdk.AMSearchResults in project OpenAM by OpenRock.
the class AMClientCapData method getMinimalClientInfo.
/**
* Demand Load stuff
*/
/**
* Gets a minimal set of client properties for all clients.
*
* @return Set of Maps. Each Map has the propertyNames for the Key and Value
* is Set of Property values. By default, the keys returned are
* clientType, userAgent & parentID.
*/
public Set getMinimalClientInfo() {
Set clients = new HashSet();
AMSearchControl amsrchCntrl = new AMSearchControl();
amsrchCntrl.setReturnAttributes(minClient);
try {
long st = System.currentTimeMillis();
AMSearchResults results = amClientOrg.searchEntities("*", amsrchCntrl, null, UMS_SRCH_TEMPLATE_NAME);
long end = System.currentTimeMillis();
if (debug.messageEnabled()) {
debug.message(dbStr + "getMinimalClientInfo() Srch Time (ms) = " + (end - st));
}
st = System.currentTimeMillis();
Map m = results.getResultAttributes();
Iterator keys = m.keySet().iterator();
while (keys.hasNext()) {
String dn = (String) keys.next();
Map attrsMap = (Map) m.get(dn);
Map data = parsePropertyNames(attrsMap);
clients.add(data);
}
end = System.currentTimeMillis();
if (debug.messageEnabled()) {
debug.message(dbStr + "getMinimalClientInfo() Parse Time (ms) = " + (end - st));
}
} catch (Exception e) {
debug.error(dbStr + " getMinimalClientInfo(): Search Error: ", e);
}
return clients;
}
Aggregations