Skip to content

Instantly share code, notes, and snippets.

@wgthom
Created February 16, 2016 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wgthom/54e08c7d44b802f720ce to your computer and use it in GitHub Desktop.
Save wgthom/54e08c7d44b802f720ce to your computer and use it in GitHub Desktop.
/**
* Example change log consumer based on ChangeLogConsumerBaseImpl. ChangeLogConsumerBaseImpl handles
* the mapping of change log event to methods, the processing loop, and exception handling.
*/
public class PrintChangeLogConsumer extends ChangeLogConsumerBaseImpl {
private static final Logger LOG = LoggerFactory.getLogger(PrintChangeLogConsumer.class);
@Override
protected void addGroup(ChangeLogEntry changeLogEntry, String consumerName) {
final String groupName = changeLogEntry.retrieveValueForLabel(ChangeLogLabels.GROUP_ADD.name);
LOG.debug("{} add group {}.", consumerName, groupName);
// final edu.internet2.middleware.grouper.Group group = connector.fetchGrouperGroup(groupName);
}
@Override
protected void updateGroup(ChangeLogEntry changeLogEntry, String consumerName){
final String groupName = changeLogEntry.retrieveValueForLabel(ChangeLogLabels.GROUP_UPDATE.name);
LOG.debug("{} update group {}.", consumerName, groupName);
}
@Override
protected void deleteGroup(ChangeLogEntry changeLogEntry, String consumerName){
final String groupName = changeLogEntry.retrieveValueForLabel(ChangeLogLabels.GROUP_DELETE.name);
LOG.debug("{} delete group {}.", consumerName, groupName);
}
@Override
protected void addMembership(ChangeLogEntry changeLogEntry, String consumerName){
final String groupName = changeLogEntry.retrieveValueForLabel(ChangeLogLabels.MEMBERSHIP_ADD.groupName);
final String subjectId = changeLogEntry.retrieveValueForLabel(ChangeLogLabels.MEMBERSHIP_ADD.subjectId);
LOG.debug("{} add {} to group {}.", new Object[] {consumerName, subjectId, groupName});
}
@Override
protected void deleteMembership(ChangeLogEntry changeLogEntry, String consumerName){
final String groupName = changeLogEntry.retrieveValueForLabel(ChangeLogLabels.MEMBERSHIP_DELETE.groupName);
final String subjectId = changeLogEntry.retrieveValueForLabel(ChangeLogLabels.MEMBERSHIP_DELETE.subjectId);
LOG.debug("{} remove {} from group {}.", new Object[] {consumerName, subjectId, groupName});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment