use of com.iplanet.ums.SearchControl in project OpenAM by OpenRock.
the class DirectoryManagerImpl method search2.
public Map search2(String token, String entryDN, String searchFilter, List sortKeys, int startIndex, int beforeCount, int afterCount, String jumpTo, int timeOut, int maxResults, int scope, boolean allAttributes, String[] attrNames) 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);
// 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 SearchControl): entryDN=" + entryDN + "the exception is: " + amex);
}
throw convertException(amex);
}
}
use of com.iplanet.ums.SearchControl 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.ums.SearchControl in project OpenAM by OpenRock.
the class AMObjectImpl method searchObjects.
protected AMSearchResults searchObjects(String namingAttr, String objectClassFilter, String wildcard, AMSearchControl searchControl, String avfilter) throws AMException, SSOException {
SSOTokenManager.getInstance().validateToken(token);
StringBuilder filterSB = new StringBuilder();
filterSB.append("(&").append(constructFilter(namingAttr, objectClassFilter, wildcard));
if (avfilter != null) {
filterSB.append(avfilter);
}
filterSB.append(")");
if (debug.messageEnabled()) {
debug.message("AMObjectImpl.searchObjects(" + namingAttr + ", " + objectClassFilter + ", " + wildcard + ", " + avfilter + "): DN=" + entryDN + ", level " + searchControl.getSearchScope());
debug.message("AMObjectImpl.searchObjects(): filter: " + filterSB.toString());
}
SearchControl sc = searchControl.getSearchControl();
String[] returnAttrs = searchControl.getReturnAttributes();
return dsServices.search(token, entryDN, filterSB.toString(), sc, returnAttrs);
}
use of com.iplanet.ums.SearchControl in project OpenAM by OpenRock.
the class AMGroupImpl method searchUsers.
/**
* Searches for users in this group using wildcards. Wildcards can be
* specified such as a*, *, *a.
*
* @param wildcard
* wildcard pattern to be used in the search
* @param avPairs
* attribute-value pairs to match when searching users
* @param searchControl
* specifies the size limit and time limit
*
* @return AMSearchResults which contains a Set DNs of Users matching the
* search
*
* @throws AMException
* if there is an internal error in the AM Store
* @throws SSOException
* if the sign on is no longer valid
*/
public AMSearchResults searchUsers(AMSearchControl searchControl, String avfilter) throws AMException, SSOException {
int scope;
String base;
String gfilter;
if (profileType == DYNAMIC_GROUP || profileType == ASSIGNABLE_DYNAMIC_GROUP) {
String[] array = dsServices.getGroupFilterAndScope(token, entryDN, profileType);
scope = Integer.parseInt(array[0]);
base = array[1];
gfilter = array[2];
} else {
scope = AMConstants.SCOPE_SUB;
base = getOrganizationDN();
gfilter = "(iplanet-am-static-group-dn=" + entryDN + ")";
}
String filter = "(&" + gfilter + getSearchFilter(AMObject.USER) + avfilter + ")";
if (debug.messageEnabled()) {
debug.message("AMGroupImpl.searchUsers: " + filter);
}
searchControl.setSearchScope(scope);
SearchControl sc = searchControl.getSearchControl();
String[] returnAttrs = searchControl.getReturnAttributes();
return dsServices.search(super.token, base, filter, sc, returnAttrs);
}
use of com.iplanet.ums.SearchControl in project OpenAM by OpenRock.
the class AMObjectImpl method searchObjects.
protected AMSearchResults searchObjects(int[] objectTypes, String wildcard, Map avPairs, AMSearchControl searchControl) throws AMException, SSOException {
SSOTokenManager.getInstance().validateToken(token);
StringBuilder filterSB = new StringBuilder();
filterSB.append("(&");
filterSB.append("(|");
for (int i = 0; i < objectTypes.length; i++) {
String namingAttr = AMNamingAttrManager.getNamingAttr(objectTypes[i]);
String objectClassFilter = getSearchFilter(objectTypes[i]);
filterSB.append(constructFilter(namingAttr, objectClassFilter, wildcard));
}
filterSB.append(")");
if ((avPairs != null) && !avPairs.isEmpty()) {
filterSB.append(constructFilter(avPairs));
}
filterSB.append(")");
if (debug.messageEnabled()) {
debug.message("AMObjectImpl.searchObjects(): filter: " + filterSB.toString());
}
SearchControl sc = searchControl.getSearchControl();
String[] returnAttrs = searchControl.getReturnAttributes();
return dsServices.search(token, entryDN, filterSB.toString(), sc, returnAttrs);
}
Aggregations