public void createGroup ( GroupForm groupForm , JsonEntityBean parent , IPerson creator ) { if ( ! canCreateMemberGroup ( creator , parent . getId ( ) ) ) { throw new RuntimeAuthorizationException ( creator , IPermission . CREATE_GROUP_ACTIVITY , groupForm . getKey ( ) ) ; } if ( log . isDebugEnabled ( ) ) { log . debug ( "Creating new group for group form [" + groupForm . toString ( ) + "] and parent [" + parent . toString ( ) + "]" ) ; } // get the entity type of the parent group EntityEnum type = EntityEnum . getEntityEnum ( groupForm . getType ( ) ) ; // create a new group with the parent's entity type IEntityGroup group = GroupService . newGroup ( type . getClazz ( ) ) ; // find the current version of this group entity group . setCreatorID ( creator . getUserName ( ) ) ; group . setName ( groupForm . getName ( ) ) ; group . setDescription ( groupForm . getDescription ( ) ) ; // add all the group membership information from the group form // to the group for ( JsonEntityBean child : groupForm . getMembers ( ) ) { EntityEnum childType = EntityEnum . getEntityEnum ( child . getEntityTypeAsString ( ) ) ; if ( childType . isGroup ( ) ) { IEntityGroup member = GroupService . findGroup ( child . getId ( ) ) ; group . addChild ( member ) ; } else { IGroupMember member = GroupService . getGroupMember ( child . getId ( ) , type . getClazz ( ) ) ; group . addChild ( member ) ; } } // save the group, updating both its basic information and group membership group . update ( ) ; // add this group to the membership list for the specified parent IEntityGroup parentGroup = GroupService . findGroup ( parent . getId ( ) ) ; parentGroup . addChild ( group ) ; parentGroup . updateMembers ( ) ; }
Create a new group under the specified parent . The new group will automatically be added to the parent group .