Skip to Content.
Sympa Menu

grouper-dev - RE: [grouper-dev] Issue with the groupPreUpdate value

Subject: Grouper Developers Forum

List archive

RE: [grouper-dev] Issue with the groupPreUpdate value


Chronological Thread 
  • From: Chris Hyzer <>
  • To: "Begum, Sheema" <>, "" <>
  • Subject: RE: [grouper-dev] Issue with the groupPreUpdate value
  • Date: Fri, 26 Jun 2015 15:01:16 +0000
  • Accept-language: en-US

It works for me.  Note, you need the latest 2.2.1 with all patches for hooks to work with moves and copies.

 

Configure this hook in grouper.properties:

 

hooks.group.class = edu.internet2.middleware.grouper.hooks.GroupHooksImpl3

 

This is the output:

 

new name: test:someGroupNewName

old name: test:someGroupOldName

 

 

 

/**

* @author mchyzer

* $Id$

*/

package edu.internet2.middleware.grouper.hooks;

 

import edu.internet2.middleware.grouper.Group;

import edu.internet2.middleware.grouper.GroupFinder;

import edu.internet2.middleware.grouper.GroupSave;

import edu.internet2.middleware.grouper.GrouperSession;

import edu.internet2.middleware.grouper.hooks.beans.HooksContext;

import edu.internet2.middleware.grouper.hooks.beans.HooksGroupBean;

import edu.internet2.middleware.grouper.internal.dao.QueryOptions;

 

 

/**

*

 */

public class GroupHooksImpl3 extends GroupHooks {

 

  /**

   *

   * @see edu.internet2.middleware.grouper.hooks.GroupHooks#groupPreUpdate(edu.internet2.middleware.grouper.hooks.beans.HooksContext, edu.internet2.middleware.grouper.hooks.beans.HooksGroupBean)

   */

  public void groupPreUpdate(HooksContext hooksContext, HooksGroupBean preUpdateBean) {

    Group group = preUpdateBean.getGroup();

    

    System.out.println("new name: " + group.getName());

 

    group = GroupFinder.findByUuid(GrouperSession.staticGrouperSession(), group.getId(), true,new QueryOptions().secondLevelCache(false));

   

    System.out.println("old name: " + group.getName());

   

    

  }

 

 

  /**

   *

   */

  public GroupHooksImpl3() {

  }

 

  /**

   * @param args

   */

  public static void main(String[] args) {

 

    GrouperSession grouperSession = GrouperSession.startRootSession();

   

    Group group = new GroupSave(grouperSession).assignCreateParentStemsIfNotExist(true)

        .assignName("test:someGroupOldName").save();

   

    group.setExtension("someGroupNewName");

    group.store();

   

  }

 

}

 

 

From: [mailto:] On Behalf Of Begum, Sheema
Sent: Friday, June 26, 2015 5:21 AM
To:
Subject: [grouper-dev] Issue with the groupPreUpdate value

 

Hi,

 

We are having an issue with the groupPreUpdate, here is the scenario:

 

 

We want to check if the groupName has restricted word in it on both Insert and Update operations. Insert is fine, but we are having issue with the Update operation as it is getting only the old value but not the new value.

 

Example: 

  If the existing group name is "TestGroup" and it being updated to "TestGroupUpdated"

 

In the below method when we print the value of the group name we are getting "TestGroup" while we are expecting the new value "TestGroupUpdated"

 

public void groupPreUpdate(HooksContext hooksContext, HooksGroupBean preUpdateBean) { Group group = preUpdateBean.getGroup(); String name = StringUtils.defaultString(group.getName()); } }

 

Please let us know, how we can get the new value for the group Name.

 

Thanks,

Sheema.




Archive powered by MHonArc 2.6.16.

Top of Page