Skip to content

Commit

Permalink
Merge branch 'main' into ma/update-user-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek authored Nov 26, 2024
2 parents d599ce6 + 26a6ede commit efbb568
Show file tree
Hide file tree
Showing 80 changed files with 1,403 additions and 1,476 deletions.
7 changes: 1 addition & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="Castle.Core" Version="5.1.1" />
<PackageVersion Include="DocumentFormat.OpenXml" Version="3.1.1" />
<PackageVersion Include="Elastic.Clients.Elasticsearch" Version="8.16.1" />
<PackageVersion Include="Fluid.Core" Version="2.12.0" />
<PackageVersion Include="GraphQL" Version="8.2.1" />
<PackageVersion Include="GraphQL.DataLoader" Version="8.2.1" />
Expand Down Expand Up @@ -57,7 +58,6 @@
<PackageVersion Include="MiniProfiler.AspNetCore.Mvc" Version="4.3.8" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="ncrontab" Version="3.3.3" />
<PackageVersion Include="NEST" Version="7.17.5" />
<PackageVersion Include="NJsonSchema" Version="11.0.2" />
<PackageVersion Include="NLog.Web.AspNetCore" Version="5.3.14" />
<PackageVersion Include="NodaTime" Version="3.2.0" />
Expand Down Expand Up @@ -129,24 +129,19 @@
└─ System.IO.Packaging (v8.0.0)
-->
<PackageVersion Include="System.IO.Packaging" Version="8.0.1" />

<!--
YesSql (v5.1.1)
└─ YesSql.Provider.SqlServer (v5.1.1)
└─ Microsoft.Data.SqlClient (v5.2.1)
└─ System.Runtime.Caching (v8.0.0)
-->
<PackageVersion Include="System.Runtime.Caching" Version="8.0.1" />

<PackageVersion Include="System.Private.Uri" Version="4.3.2" />

<!-- Several transitive dependencies on 8.0.4 and lower which has known vulnerabilities -->
<PackageVersion Include="System.Text.Json" Version="8.0.5" />

<!-- Several transitive dependencies on 8.0.0 which has known vulnerabilities -->
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
</ItemGroup>

<!-- These versions are used for the NuGet packages that are dependent on the current TFM -->
<!-- Versions are preset for the default TFM (there may be no TFM in an evaluation phase) -->
<PropertyGroup>
Expand Down
11 changes: 2 additions & 9 deletions OrchardCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Roles.Core", "s
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.AutoSetup", "src\OrchardCore.Modules\OrchardCore.AutoSetup\OrchardCore.AutoSetup.csproj", "{1E76C17C-099A-4E6D-BC26-E93CBA4D0BD6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Search.Elasticsearch.Abstractions", "src\OrchardCore\OrchardCore.Search.Elasticsearch.Abstractions\OrchardCore.Search.Elasticsearch.Abstractions.csproj", "{E6A90BFD-AB5C-4AED-A5AB-799136AB1521}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Search.Elasticsearch.Core", "src\OrchardCore\OrchardCore.Search.Elasticsearch.Core\OrchardCore.Search.Elasticsearch.Core.csproj", "{848C919B-6829-4758-9E59-51F13D25ABBC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Search.Elasticsearch", "src\OrchardCore.Modules\OrchardCore.Search.Elasticsearch\OrchardCore.Search.Elasticsearch.csproj", "{B6A54EA8-F285-436D-8257-6F6EDE4C3339}"
Expand Down Expand Up @@ -529,9 +527,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Sms.Azure", "sr
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.UrlRewriting", "src\OrchardCore.Modules\OrchardCore.UrlRewriting\OrchardCore.UrlRewriting.csproj", "{D0F8B342-BDA8-44CB-AA43-7A65C79636A2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrchardCore.UrlRewriting.Abstractions", "src\OrchardCore\OrchardCore.UrlRewriting.Abstractions\OrchardCore.UrlRewriting.Abstractions.csproj", "{675C8A76-C64F-47EC-B4F5-06D4F2D9662A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.UrlRewriting.Abstractions", "src\OrchardCore\OrchardCore.UrlRewriting.Abstractions\OrchardCore.UrlRewriting.Abstractions.csproj", "{675C8A76-C64F-47EC-B4F5-06D4F2D9662A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrchardCore.UrlRewriting.Core", "src\OrchardCore\OrchardCore.UrlRewriting.Core\OrchardCore.UrlRewriting.Core.csproj", "{7B18DD99-A7BB-4297-8679-D87289758756}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.UrlRewriting.Core", "src\OrchardCore\OrchardCore.UrlRewriting.Core\OrchardCore.UrlRewriting.Core.csproj", "{7B18DD99-A7BB-4297-8679-D87289758756}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -1223,10 +1221,6 @@ Global
{1E76C17C-099A-4E6D-BC26-E93CBA4D0BD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E76C17C-099A-4E6D-BC26-E93CBA4D0BD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E76C17C-099A-4E6D-BC26-E93CBA4D0BD6}.Release|Any CPU.Build.0 = Release|Any CPU
{E6A90BFD-AB5C-4AED-A5AB-799136AB1521}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E6A90BFD-AB5C-4AED-A5AB-799136AB1521}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E6A90BFD-AB5C-4AED-A5AB-799136AB1521}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E6A90BFD-AB5C-4AED-A5AB-799136AB1521}.Release|Any CPU.Build.0 = Release|Any CPU
{848C919B-6829-4758-9E59-51F13D25ABBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{848C919B-6829-4758-9E59-51F13D25ABBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{848C919B-6829-4758-9E59-51F13D25ABBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -1603,7 +1597,6 @@ Global
{1D0144D0-9E6D-441B-A393-B62F6DC8E97E} = {90030E85-0C4F-456F-B879-443E8A3F220D}
{15E0499A-815D-4E98-B1E4-1C9D7B3D1461} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{1E76C17C-099A-4E6D-BC26-E93CBA4D0BD6} = {A066395F-6F73-45DC-B5A6-B4E306110DCE}
{E6A90BFD-AB5C-4AED-A5AB-799136AB1521} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{848C919B-6829-4758-9E59-51F13D25ABBC} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{B6A54EA8-F285-436D-8257-6F6EDE4C3339} = {90030E85-0C4F-456F-B879-443E8A3F220D}
{F06E4E20-3675-4BA5-AD2D-4538FAB154D5} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,16 @@ public sealed class AdminController : Controller
private readonly ILiquidTemplateManager _liquidTemplateManager;
private readonly IContentDefinitionManager _contentDefinitionManager;
private readonly IAuthorizationService _authorizationService;
private readonly IElasticQueryService _queryService;
private readonly ElasticIndexManager _elasticIndexManager;
private readonly ElasticIndexingService _elasticIndexingService;
private readonly ElasticIndexSettingsService _elasticIndexSettingsService;
private readonly ElasticsearchIndexManager _elasticIndexManager;
private readonly ElasticsearchIndexingService _elasticIndexingService;
private readonly ElasticsearchIndexSettingsService _elasticIndexSettingsService;
private readonly JavaScriptEncoder _javaScriptEncoder;
private readonly ElasticsearchOptions _elasticSearchOptions;
private readonly INotifier _notifier;
private readonly ILogger _logger;
private readonly IOptions<TemplateOptions> _templateOptions;
private readonly ElasticConnectionOptions _elasticConnectionOptions;
private readonly IShapeFactory _shapeFactory;
private readonly ElasticsearchQueryService _elasticQueryService;
private readonly ElasticsearchConnectionOptions _elasticConnectionOptions;
private readonly ILocalizationService _localizationService;

internal readonly IStringLocalizer S;
Expand All @@ -63,17 +62,16 @@ public AdminController(
ILiquidTemplateManager liquidTemplateManager,
IContentDefinitionManager contentDefinitionManager,
IAuthorizationService authorizationService,
IElasticQueryService queryService,
ElasticIndexManager elasticIndexManager,
ElasticIndexingService elasticIndexingService,
ElasticIndexSettingsService elasticIndexSettingsService,
ElasticsearchIndexManager elasticIndexManager,
ElasticsearchIndexingService elasticIndexingService,
ElasticsearchIndexSettingsService elasticIndexSettingsService,
JavaScriptEncoder javaScriptEncoder,
IOptions<ElasticsearchOptions> elasticSearchOptions,
INotifier notifier,
ILogger<AdminController> logger,
IOptions<TemplateOptions> templateOptions,
IOptions<ElasticConnectionOptions> elasticConnectionOptions,
IShapeFactory shapeFactory,
IOptions<ElasticsearchConnectionOptions> elasticConnectionOptions,
ElasticsearchQueryService elasticQueryService,
ILocalizationService localizationService,
IStringLocalizer<AdminController> stringLocalizer,
IHtmlLocalizer<AdminController> htmlLocalizer)
Expand All @@ -83,7 +81,6 @@ public AdminController(
_liquidTemplateManager = liquidTemplateManager;
_contentDefinitionManager = contentDefinitionManager;
_authorizationService = authorizationService;
_queryService = queryService;
_elasticIndexManager = elasticIndexManager;
_elasticIndexingService = elasticIndexingService;
_elasticIndexSettingsService = elasticIndexSettingsService;
Expand All @@ -92,21 +89,24 @@ public AdminController(
_notifier = notifier;
_logger = logger;
_templateOptions = templateOptions;
_elasticQueryService = elasticQueryService;
_elasticConnectionOptions = elasticConnectionOptions.Value;
_shapeFactory = shapeFactory;
_localizationService = localizationService;
S = stringLocalizer;
H = htmlLocalizer;
}

public async Task<IActionResult> Index(ContentOptions options, PagerParameters pagerParameters)
public async Task<IActionResult> Index(
ContentOptions options,
PagerParameters pagerParameters,
[FromServices] IShapeFactory shapeFactory)
{
if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes))
{
return Forbid();
}

if (!_elasticConnectionOptions.FileConfigurationExists())
if (!_elasticConnectionOptions.ConfigurationExists())
{
return NotConfigured();
}
Expand Down Expand Up @@ -137,7 +137,7 @@ public async Task<IActionResult> Index(ContentOptions options, PagerParameters p
routeData.Values.TryAdd(_optionsSearch, options.Search);
}

var pagerShape = await _shapeFactory.PagerAsync(pager, totalIndexes, routeData);
var pagerShape = await shapeFactory.PagerAsync(pager, totalIndexes, routeData);

var model = new AdminIndexViewModel
{
Expand All @@ -153,7 +153,6 @@ public async Task<IActionResult> Index(ContentOptions options, PagerParameters p
new SelectListItem(S["Delete"], nameof(ContentsBulkAction.Remove)),
];


return View(model);
}

Expand All @@ -162,7 +161,7 @@ public async Task<IActionResult> Index(ContentOptions options, PagerParameters p
public IActionResult IndexFilterPOST(AdminIndexViewModel model)
=> RedirectToAction(nameof(Index), new RouteValueDictionary
{
{ _optionsSearch, model.Options.Search }
{ _optionsSearch, model.Options.Search },
});

public async Task<IActionResult> Edit(string indexName = null)
Expand All @@ -175,7 +174,7 @@ public async Task<IActionResult> Edit(string indexName = null)
return Forbid();
}

if (!_elasticConnectionOptions.FileConfigurationExists())
if (!_elasticConnectionOptions.ConfigurationExists())
{
return NotConfigured();
}
Expand Down Expand Up @@ -214,7 +213,7 @@ public async Task<ActionResult> EditPost(ElasticIndexSettingsViewModel model, st
return Forbid();
}

if (!_elasticConnectionOptions.FileConfigurationExists())
if (!_elasticConnectionOptions.ConfigurationExists())
{
return BadRequest();
}
Expand Down Expand Up @@ -314,7 +313,7 @@ public async Task<ActionResult> Reset(string id)
return Forbid();
}

if (!_elasticConnectionOptions.FileConfigurationExists())
if (!_elasticConnectionOptions.ConfigurationExists())
{
return BadRequest();
}
Expand All @@ -340,7 +339,7 @@ public async Task<ActionResult> Rebuild(string id)
return Forbid();
}

if (!_elasticConnectionOptions.FileConfigurationExists())
if (!_elasticConnectionOptions.ConfigurationExists())
{
return BadRequest();
}
Expand Down Expand Up @@ -378,7 +377,7 @@ public async Task<ActionResult> Delete(ElasticIndexSettingsViewModel model)
return Forbid();
}

if (!_elasticConnectionOptions.FileConfigurationExists())
if (!_elasticConnectionOptions.ConfigurationExists())
{
return BadRequest();
}
Expand Down Expand Up @@ -412,7 +411,7 @@ public async Task<ActionResult> ForceDelete(ElasticIndexSettingsViewModel model)
return Forbid();
}

if (!_elasticConnectionOptions.FileConfigurationExists())
if (!_elasticConnectionOptions.ConfigurationExists())
{
return BadRequest();
}
Expand Down Expand Up @@ -456,14 +455,14 @@ public async Task<IActionResult> SyncSettings()
return RedirectToAction(nameof(Index));
}

public async Task<IActionResult> Query(string indexName, string query)
public Task<IActionResult> Query(string indexName, string query)
{
if (!_elasticConnectionOptions.FileConfigurationExists())
if (!_elasticConnectionOptions.ConfigurationExists())
{
return NotConfigured();
return Task.FromResult<IActionResult>(NotConfigured());
}

return await Query(new AdminQueryViewModel
return Query(new AdminQueryViewModel
{
IndexName = indexName,
DecodedQuery = string.IsNullOrWhiteSpace(query)
Expand All @@ -480,7 +479,7 @@ public async Task<IActionResult> Query(AdminQueryViewModel model)
return Forbid();
}

if (!_elasticConnectionOptions.FileConfigurationExists())
if (!_elasticConnectionOptions.ConfigurationExists())
{
return BadRequest();
}
Expand Down Expand Up @@ -521,13 +520,13 @@ public async Task<IActionResult> Query(AdminQueryViewModel model)

try
{
var elasticTopDocs = await _queryService.SearchAsync(model.IndexName, tokenizedContent);
var results = await _elasticQueryService.SearchAsync(model.IndexName, tokenizedContent);

if (elasticTopDocs != null)
if (results != null)
{
model.Documents = elasticTopDocs.TopDocs.Where(x => x != null);
model.Fields = elasticTopDocs.Fields;
model.Count = elasticTopDocs.Count;
model.Documents = results.TopDocs;
model.Fields = results.Fields;
model.Count = results.Count;
}
}
catch (Exception e)
Expand All @@ -550,7 +549,7 @@ public async Task<ActionResult> IndexPost(ContentOptions options, IEnumerable<st
return Forbid();
}

if (!_elasticConnectionOptions.FileConfigurationExists())
if (!_elasticConnectionOptions.ConfigurationExists())
{
return BadRequest();
}
Expand Down Expand Up @@ -618,7 +617,7 @@ private void ValidateModel(ElasticIndexSettingsViewModel model)
{
ModelState.AddModelError(nameof(ElasticIndexSettingsViewModel.IndexName), S["The index name is required."]);
}
else if (ElasticIndexManager.ToSafeIndexName(model.IndexName) != model.IndexName)
else if (ElasticsearchIndexManager.ToSafeIndexName(model.IndexName) != model.IndexName)
{
ModelState.AddModelError(nameof(ElasticIndexSettingsViewModel.IndexName), S["The index name contains forbidden characters."]);
}
Expand All @@ -644,7 +643,7 @@ private ViewResult NotConfigured()
private static Task ProcessContentItemsAsync(string indexName)
=> HttpBackgroundJob.ExecuteAfterEndOfRequestAsync("sync-content-items-elasticsearch-" + indexName, async (scope) =>
{
var indexingService = scope.ServiceProvider.GetRequiredService<ElasticIndexingService>();
var indexingService = scope.ServiceProvider.GetRequiredService<ElasticsearchIndexingService>();
await indexingService.ProcessContentItemsAsync(indexName);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public async Task<IActionResult> DocumentsPost(ElasticApiQueryViewModel queryMod

private async Task<IQueryResults> ElasticQueryApiAsync(ElasticApiQueryViewModel queryModel, bool returnContentItems = false)
{
var elasticQuery = await _queryManager.NewAsync(ElasticQuerySource.SourceName);
var elasticQuery = await _queryManager.NewAsync(ElasticsearchQuerySource.SourceName);
elasticQuery.ReturnContentItems = returnContentItems;

elasticQuery.Put(new ElasticsearchQueryMetadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ namespace OrchardCore.Search.Elasticsearch.Drivers;

public sealed class ContentPickerFieldElasticEditorSettingsDriver : ContentPartFieldDefinitionDisplayDriver
{
private readonly ElasticIndexSettingsService _elasticIndexSettingsService;
private readonly ElasticsearchIndexSettingsService _elasticIndexSettingsService;

public ContentPickerFieldElasticEditorSettingsDriver(ElasticIndexSettingsService elasticIndexSettingsService)
public ContentPickerFieldElasticEditorSettingsDriver(ElasticsearchIndexSettingsService elasticIndexSettingsService)
{
_elasticIndexSettingsService = elasticIndexSettingsService;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

namespace OrchardCore.Search.Elasticsearch.Core.Deployment;

public sealed class ElasticIndexDeploymentStepDriver : DisplayDriver<DeploymentStep, ElasticIndexDeploymentStep>
public sealed class ElasticIndexDeploymentStepDriver : DisplayDriver<DeploymentStep, ElasticsearchIndexDeploymentStep>
{
private readonly ElasticIndexSettingsService _elasticIndexSettingsService;
private readonly ElasticsearchIndexSettingsService _elasticIndexSettingsService;

public ElasticIndexDeploymentStepDriver(ElasticIndexSettingsService elasticIndexSettingsService)
public ElasticIndexDeploymentStepDriver(ElasticsearchIndexSettingsService elasticIndexSettingsService)
{
_elasticIndexSettingsService = elasticIndexSettingsService;
}

public override Task<IDisplayResult> DisplayAsync(ElasticIndexDeploymentStep step, BuildDisplayContext context)
public override Task<IDisplayResult> DisplayAsync(ElasticsearchIndexDeploymentStep step, BuildDisplayContext context)
{
return
CombineAsync(
Expand All @@ -24,7 +24,7 @@ public override Task<IDisplayResult> DisplayAsync(ElasticIndexDeploymentStep ste
);
}

public override IDisplayResult Edit(ElasticIndexDeploymentStep step, BuildEditorContext context)
public override IDisplayResult Edit(ElasticsearchIndexDeploymentStep step, BuildEditorContext context)
{
return Initialize<ElasticIndexDeploymentStepViewModel>("ElasticIndexDeploymentStep_Fields_Edit", async model =>
{
Expand All @@ -34,7 +34,7 @@ public override IDisplayResult Edit(ElasticIndexDeploymentStep step, BuildEditor
}).Location("Content");
}

public override async Task<IDisplayResult> UpdateAsync(ElasticIndexDeploymentStep step, UpdateEditorContext context)
public override async Task<IDisplayResult> UpdateAsync(ElasticsearchIndexDeploymentStep step, UpdateEditorContext context)
{
step.IndexNames = [];

Expand Down
Loading

0 comments on commit efbb568

Please sign in to comment.