use of org.forgerock.openam.entitlement.indextree.events.ModificationEventType in project OpenAM by OpenRock.
the class IndexTreeServiceImpl method update.
/**
* {@inheritDoc}
*/
public void update(IndexChangeEvent event) {
EventType type = event.getType();
if (ModificationEventType.contains(type)) {
// Modification event received, update the appropriate cached tree.
ModificationEventType modificationType = (ModificationEventType) type;
ModificationEvent modification = (ModificationEvent) event;
String realm = modification.getRealm();
IndexRuleTree tree = indexTreeCache.get(realm);
if (tree != null) {
String pathIndex = modification.getPathIndex();
switch(modificationType) {
case ADD:
tree.addIndexRule(pathIndex);
break;
case DELETE:
tree.removeIndexRule(pathIndex);
break;
}
if (DEBUG.messageEnabled()) {
DEBUG.message(String.format("Policy path index '%s' updated for realm '%s'.", pathIndex, realm));
}
}
} else if (type == ErrorEventType.DATA_LOSS) {
// Error event received, destroy the cache as policy updates may well have been lost, resulting in cached
// trees becoming inconsistent. This will force all trees to be reloaded with clean data.
indexTreeCache.clear();
if (DEBUG.messageEnabled()) {
DEBUG.message("Potential policy path index loss, cached index trees cleared.");
}
}
}
Aggregations