Skip to Content.
Sympa Menu

grouper-dev - RE: [grouper-dev] How to add a group preDelete hook to check a group's memberships?

Subject: Grouper Developers Forum

List archive

RE: [grouper-dev] How to add a group preDelete hook to check a group's memberships?


Chronological Thread 
  • From: "Hyzer, Chris" <>
  • To: "Redman, Chad" <>, "" <>
  • Subject: RE: [grouper-dev] How to add a group preDelete hook to check a group's memberships?
  • Date: Thu, 30 May 2019 19:05:08 +0000

Weird that the hook is called after deleting memberships.  In any case, would this work in there?

 

It opens a new transaction and reads the group 😊

 

    final Group group = null;   ß-- set this to your group, need final var

   

    // the tx type of READ_WRITE_NEW gives you a new tx…   

    Set<Member> members = (Set<Member>)HibernateSession.callbackHibernateSession(GrouperTransactionType.READ_WRITE_NEW, AuditControl.WILL_NOT_AUDIT, new HibernateHandler() {

     

      public Object callback(HibernateHandlerBean hibernateHandlerBean)

          throws GrouperDAOException {

        return group.getMembers();

      }

    });

 

 

From: <> On Behalf Of Redman, Chad
Sent: Thursday, May 30, 2019 12:00 PM
To:
Subject: [grouper-dev] How to add a group preDelete hook to check a group's memberships?

 

I am working on a hook where, if a group is deleted but is a member of another group in a certain folder, delete the sync attribute in that target group before it can sync the emptied out memberships. The source groups are from a loader, so they can go out of scope and get deleted at any point, so it's not normally a manual delete. Maybe there is something built in to do this, but I thought it would work with a hook.

 

I've spent a number of hours trying to track down why a simple membership query works fine to find a group's memberships, all except where it is used in a preDelete hook. After boosting the db trace levels, I can see that the group.delete() is deleting from memberships and group_set (without committing) before calling onPreDelete(). That explains why the membership query looks different within the hook.

 

Any ideas on the approach I should take to this? Maybe this function already exists elsewhere?

 

Thanks

-Chad

 




Archive powered by MHonArc 2.6.19.

Top of Page