grouper-users - RE: [grouper-users] RE: Change Log Consumer
Subject: Grouper Users - Open Discussion List
List archive
- From: "Klug, Lawrence" <>
- To: Shilen Patel <>
- Cc: Chris Hyzer <>, "" <>
- Subject: RE: [grouper-users] RE: Change Log Consumer
- Date: Mon, 8 Oct 2012 15:40:51 +0000
- Accept-language: en-US
Hi Shilen, Thanks for the PIT code sample. Group delete notification is now working cool. I do have one more use case that I want to ask about.
The use case is “Group Add” and I want to be able to send a notification when a Plone group is created. Since Plone groups are identified by an attribute and I need the value of the attribute for the notification, Question: how can I get the associated group name from an “ATTRIBUTE_ASSIGN_VALUE_ADD” event?
Thanks, Lawrence From: Shilen Patel [mailto:]
Here's an example of getting the attribute values that were assigned to a group after the group is deleted based on the group delete change log entry. Change "etc:testAttr" to your attribute name. for (ChangeLogEntry changeLogEntry : changeLogEntryList) { currentId = changeLogEntry.getSequenceNumber(); Timestamp timestamp = changeLogEntry.getCreatedOn(); if (changeLogEntry.equalsCategoryAndAction(ChangeLogTypeBuiltin.GROUP_DELETE)) { String groupId = changeLogEntry.retrieveValueForLabel(ChangeLogLabels.GROUP_DELETE.id); PITGroup pitGroup = PITGroupFinder.findBySourceId(groupId, timestamp, timestamp, true).iterator().next(); PITAttributeDefName pitAttributeDefName = PITAttributeDefNameFinder.findByName("etc:testAttr", timestamp, timestamp, true, false).iterator().next(); Set<PITAttributeAssign> assignments = GrouperDAOFactory.getFactory().getPITAttributeAssign().findByOwnerPITGroupId(pitGroup.getId()); for (PITAttributeAssign assignment : assignments) { if (assignment.getAttributeDefNameId().equals(pitAttributeDefName.getId())) { Set<PITAttributeAssignValue> values = PITAttributeAssignValueFinder.findByPITAttributeAssign(assignment, null, null); for (PITAttributeAssignValue value : values) { // If the value was deleted as part of the group delete (not before in another transaction, then the context ids should match. Also, the end time for the value should be close
to the change log entry time if it was all deleted together. System.out.println("Value: " + value.valueString() + ", Value ended: " + value.getEndTime() + ", Value context id: " + value.getContextId() + ", change log context id: " + changeLogEntry.getContextId()); } } } } } But the above uses some internal api calls. For 2.1.3+ (not released but in the 2.1 branch in SVN), you can do the following instead: for (ChangeLogEntry changeLogEntry : changeLogEntryList) { currentId = changeLogEntry.getSequenceNumber(); Timestamp timestamp = changeLogEntry.getCreatedOn(); if (changeLogEntry.equalsCategoryAndAction(ChangeLogTypeBuiltin.GROUP_DELETE)) { String groupId = changeLogEntry.retrieveValueForLabel(ChangeLogLabels.GROUP_DELETE.id); PITGroup pitGroup = PITGroupFinder.findBySourceId(groupId, timestamp, timestamp, true).iterator().next(); PITAttributeDefName pitAttributeDefName = PITAttributeDefNameFinder.findByName("etc:testAttr", timestamp, timestamp, true, false).iterator().next(); Set<PITAttributeAssign> assignments = PITAttributeAssignFinder.findByOwnerPITGroupAndPITAttributeDefName(pitGroup, pitAttributeDefName, null, null); for (PITAttributeAssign assignment : assignments) { Set<PITAttributeAssignValue> values = PITAttributeAssignValueFinder.findByPITAttributeAssign(assignment, null, null); for (PITAttributeAssignValue value : values) { // If the value was deleted as part of the group delete (not before in another transaction, then the context ids should match. Also, the end time for the value should be close to
the change log entry time if it was all deleted together. System.out.println("Value: " + value.valueString() + ", Value ended: " + value.getEndTime() + ", Value context id: " + value.getContextId() + ", change log context id: " + changeLogEntry.getContextId()); } } } } Let me know if you have questions. Thanks! -- Shilen From: "Klug, Lawrence" <>
|
- [grouper-users] Change Log Consumer, Klug, Lawrence, 10/05/2012
- [grouper-users] RE: Change Log Consumer, Chris Hyzer, 10/05/2012
- [grouper-users] RE: Change Log Consumer, Klug, Lawrence, 10/05/2012
- Re: [grouper-users] RE: Change Log Consumer, Shilen Patel, 10/07/2012
- RE: [grouper-users] RE: Change Log Consumer, Klug, Lawrence, 10/08/2012
- Re: [grouper-users] RE: Change Log Consumer, Shilen Patel, 10/08/2012
- RE: [grouper-users] RE: Change Log Consumer, Klug, Lawrence, 10/08/2012
- Re: [grouper-users] RE: Change Log Consumer, Shilen Patel, 10/07/2012
- [grouper-users] RE: Change Log Consumer, Klug, Lawrence, 10/05/2012
- [grouper-users] RE: Change Log Consumer, Chris Hyzer, 10/05/2012
Archive powered by MHonArc 2.6.16.