private Group removeGroup ( Session session , Group group , boolean broadcast ) throws Exception { if ( group == null ) { throw new OrganizationServiceException ( "Can not remove group, since it is null" ) ; } Node groupNode = utils . getGroupNode ( session , group ) ; // need to minus one because of child "jos:memberships" node long childrenCount = ( ( ExtendedNode ) groupNode ) . getNodesLazily ( 1 ) . getSize ( ) - 1 ; if ( childrenCount > 0 ) { throw new OrganizationServiceException ( "Can not remove group till children exist" ) ; } if ( broadcast ) { preDelete ( group ) ; } removeMemberships ( groupNode , broadcast ) ; groupNode . remove ( ) ; session . save ( ) ; removeFromCache ( group . getId ( ) ) ; removeAllRelatedFromCache ( group . getId ( ) ) ; if ( broadcast ) { postDelete ( group ) ; } return group ; }
Removes group and all related membership entities . Throws exception if children exist .