/// <summary>
 /// Filters a sequence of <see cref="HiveId"/> where user <paramref name="userId"/> has permission <paramref name="permissionIds"/> by checking with <paramref name="securityService"/>.
 /// </summary>
 /// <param name="entityIds">The entity ids.</param>
 /// <param name="permissionsyService">The permissionsy service.</param>
 /// <param name="userId">The user id.</param>
 /// <param name="entityUow">The entity uow.</param>
 /// <param name="securityUow">The security uow.</param>
 /// <param name="permissionIds">The permission ids.</param>
 /// <returns></returns>
 public static IEnumerable <HiveId> FilterWithPermissions(this IEnumerable <HiveId> entityIds,
                                                          IPermissionsService permissionsyService,
                                                          HiveId userId,
                                                          IReadonlyGroupUnit <IContentStore> entityUow,
                                                          IReadonlyGroupUnit <ISecurityStore> securityUow,
                                                          params Guid[] permissionIds)
 {
     return(entityIds.Where(id => permissionsyService.GetEffectivePermissions(userId, entityUow, securityUow, id, permissionIds).AreAllAllowed()));
 }