use of org.forgerock.openam.entitlement.utils.indextree.SimpleReferenceTree in project OpenAM by OpenRock.
the class IndexTreeServiceImpl method createAndPopulateTree.
/**
* Populates a new instance of a index rule tree with policy path indexes retrieved from the associated realm.
*
* @param realm
* The realm for which policy path indexes are to be read from.
* @return A newly created tree populated with rules configured against the realm.
* @throws EntitlementException
* When an error occurs reading policy data.
*/
private IndexRuleTree createAndPopulateTree(String realm) throws EntitlementException {
IndexRuleTree indexTree = null;
String baseDN = String.format(REALM_DN_TEMPLATE, dnMapper.orgNameToDN(realm));
SSOToken token = AccessController.doPrivileged(adminAction);
if (smDAO.checkIfEntryExists(baseDN, token)) {
indexTree = new SimpleReferenceTree();
try {
Set<String> excludes = Collections.emptySet();
// Carry out search.
Iterator<SMSDataEntry> i = smDAO.search(token, baseDN, SEARCH_FILTER, 0, 0, false, false, excludes);
while (i.hasNext()) {
SMSDataEntry e = i.next();
// Suppressed warning as unchecked assignment is valid.
@SuppressWarnings("unchecked") Set<String> policyPathIndexes = e.getAttributeValues(INDEX_PATH_ATT);
indexTree.addIndexRules(policyPathIndexes);
}
} catch (SMSException smsE) {
throw new EntitlementException(52, new Object[] { baseDN }, smsE);
}
if (DEBUG.messageEnabled()) {
DEBUG.message(String.format("Index rule tree created for '%s'.", realm));
}
}
return indexTree;
}
Aggregations