Skip to Content.
Sympa Menu

grouper-users - Re: [grouper-users] RE: Change Log Consumer

Subject: Grouper Users - Open Discussion List

List archive

Re: [grouper-users] RE: Change Log Consumer


Chronological Thread 
  • From: Shilen Patel <>
  • To: "Klug, Lawrence" <>
  • Cc: Chris Hyzer <>, "" <>
  • Subject: Re: [grouper-users] RE: Change Log Consumer
  • Date: Sun, 7 Oct 2012 17:32:41 +0000
  • Accept-language: en-US

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" <>
Date: Fri, 5 Oct 2012 18:42:52 +0000
To: Chris Hyzer <>, "" <>
Subject: [grouper-users] RE: Change Log Consumer

Nice, point me to an example!

 

From: Chris Hyzer []
Sent: Friday, October 05, 2012 11:08 AM
To: Klug, Lawrence;
Subject: RE: Change Log Consumer

 

I think you should be able to get the information in the point-in-time data.  i.e. subtract a minute or whatever, and get the attribute value from then.  There still could be a race condition, but in general, it should work J.  Shilen, can you give more info on it if this is the way to go?

 

Thanks,

Chris

 

From:On Behalf Of Klug, Lawrence
Sent: Friday, October 05, 2012 11:18 AM
To:
Subject: [grouper-users] Change Log Consumer

 

Hi,

 

I’d like to identify Group delete events where the Group in has a specific attribute so that I can notify an external application(Plone).  It looks like the system deletes attributeAssign objects just prior to the delete group event (see below), so is what I’m trying to do possible?  So can I access the Group that belongs to a attributeAssign event?  How?

 

**** PLONE CHANGE LOG CONSUMER ****

Processing changeLog #74383, privilege.deletePrivilege

**** PLONE CHANGE LOG CONSUMER ****

Processing changeLog #74384, privilege.deletePrivilege

**** PLONE CHANGE LOG CONSUMER ****

Processing changeLog #74385, privilege.deletePrivilege

**** PLONE CHANGE LOG CONSUMER ****

Processing changeLog #74386, attributeAssignValue.deleteAttributeAssignValue

**** PLONE CHANGE LOG CONSUMER ****

Processing changeLog #74387, attributeAssignValue.deleteAttributeAssignValue

**** PLONE CHANGE LOG CONSUMER ****

Processing changeLog #74388, attributeAssign.deleteAttributeAssign

**** PLONE CHANGE LOG CONSUMER ****

Processing changeLog #74389, group.deleteGroup

 

Thanks,

 

Lawrence

 




Archive powered by MHonArc 2.6.16.

Top of Page