Skip to Content.
Sympa Menu

grouper-dev - Strange error while creating groups

Subject: Grouper Developers Forum

List archive

Strange error while creating groups


Chronological Thread 
  • From: Arnaud Deman <>
  • To: Grouper Dev <>
  • Subject: Strange error while creating groups
  • Date: Tue, 11 Aug 2009 16:34:16 +0200
  • Organization: GIP RECIA

Hello,

I am trying to stress test an extension of grouper that I have written and of course ... it crashes :-( .

It is no deterministic : this time it occurred after creating more than 4500 groups but sometime it happens after 300 group creations.
Initially I thought it was because of a bad use of the grouper sessions but I have corrected everything to use the callback mechanism.

I have joined the stack and the instruction which generates the exception is :

(in the method resetGroupMembersInternal)

@SuppressWarnings("unchecked")
final Set<Member> members = group.getImmediateMembers();

If someone has an idea of a direction to investigate, I would really appreciate because I am not very inspired...



Thanks,
Arnaud.


--

Arnaud Deman
GIP RECIA
Parc d'activités les Aulnaies
151 rue de la Juine - 45160 OLIVET
Tel : 02 38 42 14 69


[java] 2009-08-11 15:46:06,527 DEBUG StressTestGeneratorBatch - Creating
group st_grp_04546
[java] 2009-08-11 15:46:06,550 DEBUG StressTestGeneratorBatch -
Definition: And(objectClass=ENTAuxEnseignant, ENTAuxEnsClasses=*$723).
[java] 2009-08-11 15:46:06,550 DEBUG StressTestGeneratorBatch - -> added
to the group: esco:st01:st_grp_04546.
[java] 2009-08-11 15:46:06,585 ERROR ByObject - Exception in update:
edu.internet2.middleware.grouper.Group,
edu.internet2.middleware.grouper.hibernate.ByObject@1904a9c
[java] java.lang.IndexOutOfBoundsException: Index: 200, Size: 200,
[java] Hook ESCOGroupHooks.groupPreUpdate id: P8IUSHSB
[java] at java.util.ArrayList.RangeCheck(ArrayList.java:546)
[java] at java.util.ArrayList.get(ArrayList.java:321)
[java] at
java.util.Collections$SynchronizedList.get(Collections.java:1820)
[java] at
net.sf.ehcache.CacheManager.detectAndFixDiskStorePathConflict(CacheManager.java:306)
[java] at
net.sf.ehcache.CacheManager.configure(CacheManager.java:282)
[java] at net.sf.ehcache.CacheManager.init(CacheManager.java:225)
[java] at net.sf.ehcache.CacheManager.<init>(CacheManager.java:186)
[java] at
edu.internet2.middleware.grouper.cache.EhcacheController.initialize(EhcacheController.java:221)
[java] at
edu.internet2.middleware.grouper.cache.EhcacheController.getCache(EhcacheController.java:161)
[java] at
edu.internet2.middleware.grouper.cache.EhcacheController.getCache(EhcacheController.java:140)
[java] at
edu.internet2.middleware.grouper.privs.WheelAccessResolver.getFromIsWheelMemberCache(WheelAccessResolver.java:250)
[java] at
edu.internet2.middleware.grouper.privs.WheelAccessResolver.isWheelMember(WheelAccessResolver.java:274)
[java] at
edu.internet2.middleware.grouper.privs.WheelAccessResolver.isAndUseWheel(WheelAccessResolver.java:169)
[java] at
edu.internet2.middleware.grouper.privs.WheelAccessResolver.hasPrivilege(WheelAccessResolver.java:207)
[java] at
edu.internet2.middleware.grouper.privs.ValidatingAccessResolver.hasPrivilege(ValidatingAccessResolver.java:123)
[java] at
edu.internet2.middleware.grouper.privs.PrivilegeHelper.canRead(PrivilegeHelper.java:161)
[java] at
edu.internet2.middleware.grouper.privs.PrivilegeHelper.dispatch(PrivilegeHelper.java:348)
[java] at
edu.internet2.middleware.grouper.privs.PrivilegeHelper.canViewMembers(PrivilegeHelper.java:298)
[java] at
edu.internet2.middleware.grouper.MemberFinder.internal_findMembersByType(MemberFinder.java:107)
[java] at
edu.internet2.middleware.grouper.Group.getImmediateMembers(Group.java:1964)
[java] at
edu.internet2.middleware.grouper.Group.getImmediateMembers(Group.java:1941)
[java] at
edu.internet2.middleware.grouper.Group.getImmediateMembers(Group.java:1912)
[java] at
org.esco.dynamicgroups.dao.grouper.ResetGroupMembersDAO.resetGroupMembersInternal(ResetGroupMembersDAO.java:122)
[java] at
org.esco.dynamicgroups.dao.grouper.ResetGroupMembersCallback.callback(ResetGroupMembersDAO.java:58)
[java] at
edu.internet2.middleware.grouper.GrouperSession.callbackGrouperSession(GrouperSession.java:648)
[java] at
org.esco.dynamicgroups.dao.grouper.ResetGroupMembersDAO.resetGroupMembers(ResetGroupMembersDAO.java:97)
[java] at
org.esco.dynamicgroups.dao.grouper.GrouperDAOServiceImpl.resetGroupMembers(GrouperDAOServiceImpl.java:157)
[java] Exception in thread "main" java.lang.IndexOutOfBoundsException:
Index: 200, Size: 200,
[java] Hook ESCOGroupHooks.groupPreUpdate id: P8IUSHSB,
[java] Problem in HibernateSession: HibernateSession: isNew: true,
isReadonly: false, grouperTransactionType: READ_WRITE_NEW
[java] at java.util.ArrayList.RangeCheck(ArrayList.java:546)
[java] at
org.esco.dynamicgroups.domain.ESCODomainServiceImpl.initialize(ESCODomainServiceImpl.java:325)
[java] at java.util.ArrayList.get(ArrayList.java:321)
[java] at
org.esco.dynamicgroups.domain.ESCODomainServiceImpl.handleNewOrModifiedDynamicGroup(ESCODomainServiceImpl.java:418)
[java] at
org.esco.dynamicgroups.hooks.ESCOGroupHooks.groupPreUpdate(ESCOGroupHooks.java:181)
[java] at sun.reflect.GeneratedMethodAccessor79.invoke(Unknown
Source)
[java] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:585)
[java] at
edu.internet2.middleware.grouper.util.GrouperUtil.invokeMethod(GrouperUtil.java:3088)
[java] at
edu.internet2.middleware.grouper.hooks.logic.GrouperHooksUtils.executeHook(GrouperHooksUtils.java:471)
[java] at
edu.internet2.middleware.grouper.hooks.logic.GrouperHooksUtils.callHooksIfRegistered(GrouperHooksUtils.java:274)
[java] at
edu.internet2.middleware.grouper.hooks.logic.GrouperHooksUtils.callHooksIfRegistered(GrouperHooksUtils.java:213)
[java] at
edu.internet2.middleware.grouper.hooks.logic.GrouperHooksUtils.callHooksIfRegistered(GrouperHooksUtils.java:139)
[java] at
edu.internet2.middleware.grouper.Group.onPreUpdate(Group.java:3916)
[java] at
edu.internet2.middleware.grouper.hibernate.ByObject.update(ByObject.java:336)
[java] at
edu.internet2.middleware.grouper.hibernate.ByObjectStatic$2.callback(ByObjectStatic.java:167)
[java] at
edu.internet2.middleware.grouper.hibernate.HibernateSession.callbackHibernateSession(HibernateSession.java:385)
[java] at
edu.internet2.middleware.grouper.hibernate.ByObjectStatic.update(ByObjectStatic.java:155)
[java] at
edu.internet2.middleware.grouper.internal.dao.hib3.Hib3GroupDAO.update(Hib3GroupDAO.java:996)
[java] at
edu.internet2.middleware.grouper.Group.store(Group.java:3070)
[java] at
org.esco.dynamicgroups.util.StressTestGeneratorBatch.createGroupsInternal(StressTestGeneratorBatch.java:239)
[java] at
org.esco.dynamicgroups.util.StressTestGeneratorBatch.access$000(StressTestGeneratorBatch.java:48)
[java] at
org.esco.dynamicgroups.util.StressTestGeneratorBatch$1.callback(StressTestGeneratorBatch.java:190)
[java] at
edu.internet2.middleware.grouper.GrouperSession.callbackGrouperSession(GrouperSession.java:648)
[java] at
org.esco.dynamicgroups.util.StressTestGeneratorBatch.createGroups(StressTestGeneratorBatch.java:187)
[java] at
org.esco.dynamicgroups.util.StressTestGeneratorBatch.generate(StressTestGeneratorBatch.java:409)
[java] at
org.esco.dynamicgroups.util.StressTestGeneratorBatch.main(StressTestGeneratorBatch.java:478)
[java] 2009-08-11 15:46:06,587 ERROR ByObjectStatic - Exception in
update: edu.internet2.middleware.grouper.Group, ByObjectStatic, query: ',
cacheable: null, cacheRegion: null, tx type: null
[java] java.lang.IndexOutOfBoundsException: Index: 200, Size: 200,
[java] Hook ESCOGroupHooks.groupPreUpdate id: P8IUSHSB,
[java] Problem in HibernateSession: HibernateSession: isNew: true,
isReadonly: false, grouperTransactionType: READ_WRITE_NEW
[java] at java.util.ArrayList.RangeCheck(ArrayList.java:546)
[java] at java.util.ArrayList.get(ArrayList.java:321)
[java] at
java.util.Collections$SynchronizedList.get(Collections.java:1820)
[java] at
net.sf.ehcache.CacheManager.detectAndFixDiskStorePathConflict(CacheManager.java:306)
[java] at
net.sf.ehcache.CacheManager.configure(CacheManager.java:282)
[java] at net.sf.ehcache.CacheManager.init(CacheManager.java:225)
[java] at net.sf.ehcache.CacheManager.<init>(CacheManager.java:186)
[java] at
edu.internet2.middleware.grouper.cache.EhcacheController.initialize(EhcacheController.java:221)
[java] at
edu.internet2.middleware.grouper.cache.EhcacheController.getCache(EhcacheController.java:161)
[java] at
edu.internet2.middleware.grouper.cache.EhcacheController.getCache(EhcacheController.java:140)
[java] at
edu.internet2.middleware.grouper.privs.WheelAccessResolver.getFromIsWheelMemberCache(WheelAccessResolver.java:250)
[java] at
edu.internet2.middleware.grouper.privs.WheelAccessResolver.isWheelMember(WheelAccessResolver.java:274)
[java] at
edu.internet2.middleware.grouper.privs.WheelAccessResolver.isAndUseWheel(WheelAccessResolver.java:169)
[java] at
edu.internet2.middleware.grouper.privs.WheelAccessResolver.hasPrivilege(WheelAccessResolver.java:207)
[java] at
edu.internet2.middleware.grouper.privs.ValidatingAccessResolver.hasPrivilege(ValidatingAccessResolver.java:123)
[java] at
edu.internet2.middleware.grouper.privs.PrivilegeHelper.canRead(PrivilegeHelper.java:161)
[java] at
edu.internet2.middleware.grouper.privs.PrivilegeHelper.dispatch(PrivilegeHelper.java:348)
[java] at
edu.internet2.middleware.grouper.privs.PrivilegeHelper.canViewMembers(PrivilegeHelper.java:298)
[java] at
edu.internet2.middleware.grouper.MemberFinder.internal_findMembersByType(MemberFinder.java:107)
[java] at
edu.internet2.middleware.grouper.Group.getImmediateMembers(Group.java:1964)
[java] at
edu.internet2.middleware.grouper.Group.getImmediateMembers(Group.java:1941)
[java] at
edu.internet2.middleware.grouper.Group.getImmediateMembers(Group.java:1912)
[java] at
org.esco.dynamicgroups.dao.grouper.ResetGroupMembersDAO.resetGroupMembersInternal(ResetGroupMembersDAO.java:122)
[java] at
org.esco.dynamicgroups.dao.grouper.ResetGroupMembersCallback.callback(ResetGroupMembersDAO.java:58)
[java] at
edu.internet2.middleware.grouper.GrouperSession.callbackGrouperSession(GrouperSession.java:648)
[java] at
org.esco.dynamicgroups.dao.grouper.ResetGroupMembersDAO.resetGroupMembers(ResetGroupMembersDAO.java:97)
[java] at
org.esco.dynamicgroups.dao.grouper.GrouperDAOServiceImpl.resetGroupMembers(GrouperDAOServiceImpl.java:157)
[java] at
org.esco.dynamicgroups.domain.ESCODomainServiceImpl.initialize(ESCODomainServiceImpl.java:325)
[java] at
org.esco.dynamicgroups.domain.ESCODomainServiceImpl.handleNewOrModifiedDynamicGroup(ESCODomainServiceImpl.java:418)
[java] at
org.esco.dynamicgroups.hooks.ESCOGroupHooks.groupPreUpdate(ESCOGroupHooks.java:181)
[java] at sun.reflect.GeneratedMethodAccessor79.invoke(Unknown
Source)
[java] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:585)
[java] at
edu.internet2.middleware.grouper.util.GrouperUtil.invokeMethod(GrouperUtil.java:3088)
[java] at
edu.internet2.middleware.grouper.hooks.logic.GrouperHooksUtils.executeHook(GrouperHooksUtils.java:471)
[java] at
edu.internet2.middleware.grouper.hooks.logic.GrouperHooksUtils.callHooksIfRegistered(GrouperHooksUtils.java:274)
[java] at
edu.internet2.middleware.grouper.hooks.logic.GrouperHooksUtils.callHooksIfRegistered(GrouperHooksUtils.java:213)
[java] at
edu.internet2.middleware.grouper.hooks.logic.GrouperHooksUtils.callHooksIfRegistered(GrouperHooksUtils.java:139)
[java] at
edu.internet2.middleware.grouper.Group.onPreUpdate(Group.java:3916)
[java] at
edu.internet2.middleware.grouper.hibernate.ByObject.update(ByObject.java:336)
[java] at
edu.internet2.middleware.grouper.hibernate.ByObjectStatic$2.callback(ByObjectStatic.java:167)
[java] at
edu.internet2.middleware.grouper.hibernate.HibernateSession.callbackHibernateSession(HibernateSession.java:385)
[java] at
edu.internet2.middleware.grouper.hibernate.ByObjectStatic.update(ByObjectStatic.java:155)
[java] at
edu.internet2.middleware.grouper.internal.dao.hib3.Hib3GroupDAO.update(Hib3GroupDAO.java:996)
[java] at
edu.internet2.middleware.grouper.Group.store(Group.java:3070)
[java] at
org.esco.dynamicgroups.util.StressTestGeneratorBatch.createGroupsInternal(StressTestGeneratorBatch.java:239)
[java] at
org.esco.dynamicgroups.util.StressTestGeneratorBatch.access$000(StressTestGeneratorBatch.java:48)
[java] at
org.esco.dynamicgroups.util.StressTestGeneratorBatch$1.callback(StressTestGeneratorBatch.java:190)
[java] at
edu.internet2.middleware.grouper.GrouperSession.callbackGrouperSession(GrouperSession.java:648)
[java] at
org.esco.dynamicgroups.util.StressTestGeneratorBatch.createGroups(StressTestGeneratorBatch.java:187)
[java] at
org.esco.dynamicgroups.util.StressTestGeneratorBatch.generate(StressTestGeneratorBatch.java:409)
[java] at
org.esco.dynamicgroups.util.StressTestGeneratorBatch.main(StressTestGeneratorBatch.java:478)
[java] at
java.util.Collections$SynchronizedList.get(Collections.java:1820)
[java] at
net.sf.ehcache.CacheManager.detectAndFixDiskStorePathConflict(CacheManager.java:306)
[java] at
net.sf.ehcache.CacheManager.configure(CacheManager.java:282)
[java] at net.sf.ehcache.CacheManager.init(CacheManager.java:225)
[java] at net.sf.ehcache.CacheManager.<init>(CacheManager.java:186)
[java] at
edu.internet2.middleware.grouper.cache.EhcacheController.initialize(EhcacheController.java:221)
[java] at
edu.internet2.middleware.grouper.cache.EhcacheController.getCache(EhcacheController.java:161)
[java] at
edu.internet2.middleware.grouper.cache.EhcacheController.getCache(EhcacheController.java:140)
[java] at
edu.internet2.middleware.grouper.privs.WheelAccessResolver.getFromIsWheelMemberCache(WheelAccessResolver.java:250)
[java] at
edu.internet2.middleware.grouper.privs.WheelAccessResolver.isWheelMember(WheelAccessResolver.java:274)
[java] at
edu.internet2.middleware.grouper.privs.WheelAccessResolver.isAndUseWheel(WheelAccessResolver.java:169)
[java] at
edu.internet2.middleware.grouper.privs.WheelAccessResolver.hasPrivilege(WheelAccessResolver.java:207)
[java] at
edu.internet2.middleware.grouper.privs.ValidatingAccessResolver.hasPrivilege(ValidatingAccessResolver.java:123)
[java] at
edu.internet2.middleware.grouper.privs.PrivilegeHelper.canRead(PrivilegeHelper.java:161)
[java] at
edu.internet2.middleware.grouper.privs.PrivilegeHelper.dispatch(PrivilegeHelper.java:348)
[java] at
edu.internet2.middleware.grouper.privs.PrivilegeHelper.canViewMembers(PrivilegeHelper.java:298)
[java] at
edu.internet2.middleware.grouper.MemberFinder.internal_findMembersByType(MemberFinder.java:107)
[java] at
edu.internet2.middleware.grouper.Group.getImmediateMembers(Group.java:1964)
[java] at
edu.internet2.middleware.grouper.Group.getImmediateMembers(Group.java:1941)
[java] at
edu.internet2.middleware.grouper.Group.getImmediateMembers(Group.java:1912)
[java] at
org.esco.dynamicgroups.dao.grouper.ResetGroupMembersDAO.resetGroupMembersInternal(ResetGroupMembersDAO.java:122)
[java] at
org.esco.dynamicgroups.dao.grouper.ResetGroupMembersCallback.callback(ResetGroupMembersDAO.java:58)
[java] at
edu.internet2.middleware.grouper.GrouperSession.callbackGrouperSession(GrouperSession.java:648)
[java] at
org.esco.dynamicgroups.dao.grouper.ResetGroupMembersDAO.resetGroupMembers(ResetGroupMembersDAO.java:97)
[java] at
org.esco.dynamicgroups.dao.grouper.GrouperDAOServiceImpl.resetGroupMembers(GrouperDAOServiceImpl.java:157)
[java] at
org.esco.dynamicgroups.domain.ESCODomainServiceImpl.initialize(ESCODomainServiceImpl.java:325)
[java] at
org.esco.dynamicgroups.domain.ESCODomainServiceImpl.handleNewOrModifiedDynamicGroup(ESCODomainServiceImpl.java:418)
[java] at
org.esco.dynamicgroups.hooks.ESCOGroupHooks.groupPreUpdate(ESCOGroupHooks.java:181)
[java] at sun.reflect.GeneratedMethodAccessor79.invoke(Unknown
Source)
[java] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:585)
[java] at
edu.internet2.middleware.grouper.util.GrouperUtil.invokeMethod(GrouperUtil.java:3088)
[java] at
edu.internet2.middleware.grouper.hooks.logic.GrouperHooksUtils.executeHook(GrouperHooksUtils.java:471)
[java] at
edu.internet2.middleware.grouper.hooks.logic.GrouperHooksUtils.callHooksIfRegistered(GrouperHooksUtils.java:274)
[java] at
edu.internet2.middleware.grouper.hooks.logic.GrouperHooksUtils.callHooksIfRegistered(GrouperHooksUtils.java:213)
[java] at
edu.internet2.middleware.grouper.hooks.logic.GrouperHooksUtils.callHooksIfRegistered(GrouperHooksUtils.java:139)
[java] at
edu.internet2.middleware.grouper.Group.onPreUpdate(Group.java:3916)
[java] at
edu.internet2.middleware.grouper.hibernate.ByObject.update(ByObject.java:336)
[java] at
edu.internet2.middleware.grouper.hibernate.ByObjectStatic$2.callback(ByObjectStatic.java:167)
[java] at
edu.internet2.middleware.grouper.hibernate.HibernateSession.callbackHibernateSession(HibernateSession.java:385)
[java] at
edu.internet2.middleware.grouper.hibernate.ByObjectStatic.update(ByObjectStatic.java:155)
[java] at
edu.internet2.middleware.grouper.internal.dao.hib3.Hib3GroupDAO.update(Hib3GroupDAO.java:996)
[java] at
edu.internet2.middleware.grouper.Group.store(Group.java:3070)
[java] at
org.esco.dynamicgroups.util.StressTestGeneratorBatch.createGroupsInternal(StressTestGeneratorBatch.java:239)
[java] at
org.esco.dynamicgroups.util.StressTestGeneratorBatch.access$000(StressTestGeneratorBatch.java:48)
[java] at
org.esco.dynamicgroups.util.StressTestGeneratorBatch$1.callback(StressTestGeneratorBatch.java:190)
[java] at
edu.internet2.middleware.grouper.GrouperSession.callbackGrouperSession(GrouperSession.java:648)
[java] at
org.esco.dynamicgroups.util.StressTestGeneratorBatch.createGroups(StressTestGeneratorBatch.java:187)
[java] at
org.esco.dynamicgroups.util.StressTestGeneratorBatch.generate(StressTestGeneratorBatch.java:409)
[java] at
org.esco.dynamicgroups.util.StressTestGeneratorBatch.main(StressTestGeneratorBatch.java:478)

/**
 * 
 */
package org.esco.dynamicgroups.dao.grouper;

import edu.internet2.middleware.grouper.Group;
import edu.internet2.middleware.grouper.GrouperSession;
import edu.internet2.middleware.grouper.Member;
import edu.internet2.middleware.grouper.SubjectFinder;
import edu.internet2.middleware.grouper.exception.GrouperSessionException;
import edu.internet2.middleware.grouper.exception.InsufficientPrivilegeException;
import edu.internet2.middleware.grouper.exception.MemberDeleteException;
import edu.internet2.middleware.grouper.exception.SessionException;
import edu.internet2.middleware.grouper.misc.GrouperSessionHandler;

import java.util.Set;

import org.apache.log4j.Logger;
import org.esco.dynamicgroups.domain.definition.DynamicGroupDefinition;
import org.esco.dynamicgroups.exceptions.DynamicGroupsException;


/**
 * Callback used to reset a group with a safe use of Grouper session.
 * @author GIP RECIA - A. Deman
 * 10 août 2009
 *
 */
class ResetGroupMembersCallback implements GrouperSessionHandler {

    /** The grouper DAO Instance.*/
    private ResetGroupMembersDAO resetGroupMembersDAO;

    /** The GrouperUUID of the group. */
    private String groupUUID;

    /**
     * Builds an instance of ResetGroupMembersCallBack.
     * @param resetGroupMembersDAO The instance of Grouper DAO.
     * @param groupUUID The uuid of the considered group.
     */
    public ResetGroupMembersCallback(final ResetGroupMembersDAO resetGroupMembersDAO, 
            final String groupUUID) {

        this.resetGroupMembersDAO = resetGroupMembersDAO;
        this.groupUUID = groupUUID;
    }

    /**
     * Calls the DAO method to reset the group.
     * @param session The Grouper session.
     * @return null.
     * @throws GrouperSessionException
     * @see edu.internet2.middleware.grouper.misc.GrouperSessionHandler#callback(GrouperSession)
     */
    public Object callback(final GrouperSession session)
    throws GrouperSessionException {
        resetGroupMembersDAO.resetGroupMembersInternal(session, groupUUID);
        GrouperSession.stopQuietly(session);
        return null;
    }

}


/**
 * Resets the members of a group.
 * @author GIP RECIA - A. Deman
 * 11 août 2009
 *
 */
public class ResetGroupMembersDAO extends BaseGrouperDAO {

    /** Serial version UID.*/
    private static final long serialVersionUID = 5519931176378570682L;
    
    /** Logger. */
    private static final Logger LOGGER = Logger.getLogger(ResetGroupMembersDAO.class);
    
    /**
     * 
     * Builds an instance of ResetGroupMembersDAO.
     */
    public ResetGroupMembersDAO() {
        super();
    }
    

    /** 
     * Creates a group if it does not exist, removes all its members otherwise .
     * @param definition The definition of the group.
     * @see org.esco.dynamicgroups.dao.grouper.IGroupsDAOService#resetGroupMembers(DynamicGroupDefinition)
     */
    public void resetGroupMembers(final DynamicGroupDefinition definition) {
        try {
            final GrouperSession session = GrouperSession.start(SubjectFinder.findRootSubject(), false);
            GrouperSession.callbackGrouperSession(session, 
                    new ResetGroupMembersCallback(this, definition.getGroupUUID()));
        } catch (SessionException e) {
            LOGGER.error(e, e);
        }
    }


    /** 
     * Creates a group if it does not exist, removes all its members otherwise .
     * @param session The Grouper session to use.
     * @param groupUUID The UUID of the group.
     */
    public void resetGroupMembersInternal(final GrouperSession session, final String groupUUID) {

        final Group group = retrieveGroup(session, groupUUID);

        if (group == null) {
            LOGGER.error("Error the group " + groupUUID + " can't be found.");

        } else {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Resetting group: " + groupUUID);
            }
            @SuppressWarnings("unchecked") 
            final Set<Member> members = group.getImmediateMembers();
            for (Member member : members) {
                try {
                    group.deleteMember(new ESCODeletedSubjectImpl(member.getSubjectId()));
                } catch (InsufficientPrivilegeException e) {
                    LOGGER.error(e, e);
                    throw new DynamicGroupsException(e);
                } catch (MemberDeleteException e) {
                    LOGGER.error(e, e);
                    throw new DynamicGroupsException(e);
                } 
            }
        }
    }


}



Archive powered by MHonArc 2.6.16.

Top of Page