use of org.forgerock.opendj.ldap.controls.EntryChangeNotificationResponseControl in project OpenAM by OpenRock.
the class IndexChangeHandler method handleEntry.
@Override
public boolean handleEntry(SearchResultEntry entry) {
EntryChangeNotificationResponseControl control = null;
try {
// Retrieve details of the policy change.
control = entry.getControl(EntryChangeNotificationResponseControl.DECODER, new DecodeOptions());
} catch (DecodeException dE) {
DEBUG.error("Error occurred attempting to read policy rule change.", dE);
// Notify observers of the exception and proceed no further.
observable.notifyObservers(ErrorEventType.SEARCH_FAILURE.createEvent());
return true;
}
// Extract the realm from the DN to be passed as part of the event.
String dn = entry.getName().toString();
String orgName = dn.substring(dn.indexOf(SERVICE_DECLARATION) + SERVICE_DECLARATION.length());
String realm = dnMapper.orgNameToRealmName(orgName);
// Retrieve all sunxmlKeyValue attributes.
Attribute attributes = entry.getAttribute(AttributeDescription.valueOf("sunxmlKeyValue"));
for (ByteString attrValue : attributes) {
String attStrValue = attrValue.toString();
if (attStrValue.startsWith(INDEX_PATH_ATT)) {
// Extract the path index out of the attribute value.
String pathIndex = attStrValue.substring(INDEX_PATH_ATT.length() + 1);
switch(control.getChangeType()) {
case MODIFY:
// this will result in the old index remaining.
case ADD:
observable.notifyObservers(ModificationEventType.ADD.createEvent(pathIndex, realm));
break;
case DELETE:
observable.notifyObservers(ModificationEventType.DELETE.createEvent(pathIndex, realm));
break;
}
}
}
return true;
}
Aggregations