Search in sources :

Example 6 with AMSearchResults

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);
    }
}
Also used : HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) AMException(com.iplanet.am.sdk.AMException) SortKey(com.iplanet.ums.SortKey) SearchControl(com.iplanet.ums.SearchControl) AMSearchResults(com.iplanet.am.sdk.AMSearchResults) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap)

Example 7 with AMSearchResults

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;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) AMSearchControl(com.iplanet.am.sdk.AMSearchControl) Iterator(java.util.Iterator) AMSearchResults(com.iplanet.am.sdk.AMSearchResults) HashMap(java.util.HashMap) Map(java.util.Map) SSOException(com.iplanet.sso.SSOException) HashSet(java.util.HashSet)

Aggregations

AMSearchResults (com.iplanet.am.sdk.AMSearchResults)7 Map (java.util.Map)5 AMException (com.iplanet.am.sdk.AMException)4 SortKey (com.iplanet.ums.SortKey)4 HashMap (java.util.HashMap)4 SearchControl (com.iplanet.ums.SearchControl)3 Set (java.util.Set)3 AMHashMap (com.iplanet.am.sdk.AMHashMap)2 AMSearchControl (com.iplanet.am.sdk.AMSearchControl)2 SSOException (com.iplanet.sso.SSOException)2 PersistentObject (com.iplanet.ums.PersistentObject)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)2 AMEntryExistsException (com.iplanet.am.sdk.AMEntryExistsException)1 AMEventManagerException (com.iplanet.am.sdk.AMEventManagerException)1 AMObject (com.iplanet.am.sdk.AMObject)1 AMOrganization (com.iplanet.am.sdk.AMOrganization)1 AMStoreConnection (com.iplanet.am.sdk.AMStoreConnection)1