private boolean addGroupToGroup(String tenantName,PrincipalId groupId,String groupName) throws Exception {
  try {
    ValidateUtil.validateNotEmpty(tenantName,"Tenant name");
    ValidateUtil.validateNotNull(groupId,"Group ID");
    ValidateUtil.validateNotEmpty(groupName,"Group name");
    TenantInformation tenantInfo=findTenant(tenantName);
    ServerUtils.validateNotNullTenant(tenantInfo,tenantName);
    ISystemDomainIdentityProvider provider=tenantInfo.findSystemProvider();
    ServerUtils.validateNotNullSystemIdp(provider,tenantName);
    if (provider.findGroup(groupId) == null) {
      Group group=findGroup(tenantName,groupId);
      if (group != null) {
        validateObjectIdNotNull(group);
        PrincipalId newGroupId=getFspIdForSystemDomain(provider,group);
        return provider.addGroupToGroup(newGroupId,groupName);
      }
    }
    return provider.addGroupToGroup(groupId,groupName);
  }
 catch (  Exception ex) {
    logger.error(String.format("Failed to add group [%s@%s] to group [%s] in tenant [%s]",groupId != null ? groupId.getName() : "null",groupId != null ? groupId.getDomain() : "null",groupName,tenantName));
    throw ex;
  }
}

private boolean addGroupToGroup ( String tenantName , PrincipalId groupId , String groupName ) throws Exception { try { ValidateUtil . validateNotEmpty ( tenantName , "Tenant name" ) ; ValidateUtil . validateNotNull ( groupId , "Group ID" ) ; ValidateUtil . validateNotEmpty ( groupName , "Group name" ) ; TenantInformation tenantInfo = findTenant ( tenantName ) ; ServerUtils . validateNotNullTenant ( tenantInfo , tenantName ) ; ISystemDomainIdentityProvider provider = tenantInfo . findSystemProvider ( ) ; ServerUtils . validateNotNullSystemIdp ( provider , tenantName ) ; if ( provider . findGroup ( groupId ) == null ) { Group group = findGroup ( tenantName , groupId ) ; if ( group != null ) { validateObjectIdNotNull ( group ) ; PrincipalId newGroupId = getFspIdForSystemDomain ( provider , group ) ; return provider . addGroupToGroup ( newGroupId , groupName ) ; } } return provider . addGroupToGroup ( groupId , groupName ) ; } catch ( Exception ex ) { logger . error ( String . format ( "Failed to add group [%s@%s] to group [%s] in tenant [%s]" , groupId != null ? groupId . getName ( ) : "null" , groupId != null ? groupId . getDomain ( ) : "null" , groupName , tenantName ) ) ; throw ex ; } }
adds a security group to another in the tenant ' s system domain . applies to system provider only . for external provider , we have read privilege only . if the group is already exist , nothing is changed .
