Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a63c7cd634 | ||
|
|
6093105cb4 | ||
|
|
83f29f96f5 | ||
|
|
1cfce24715 | ||
|
|
56bc960891 | ||
|
|
f7a5525d4c | ||
|
|
af1aa90d64 | ||
|
|
77abc248fa | ||
|
|
d21bb446e2 | ||
|
|
e7fb4b9ace | ||
|
|
f56923971e | ||
|
|
d3242e6922 | ||
|
|
a61a4b29d9 | ||
|
|
5281088f59 | ||
|
|
78464c76c3 | ||
|
|
f054187c75 | ||
|
|
6f757fa466 | ||
|
|
f4b41657f4 |
@@ -339,8 +339,8 @@ public class BackOfficeController : SecurityControllerBase
|
||||
/// <summary>
|
||||
/// Called when a user links an external login provider in the back office
|
||||
/// </summary>
|
||||
/// <param name="requestModel"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="requestModel">The link login request containing provider and link key.</param>
|
||||
/// <returns>An action result indicating success or failure.</returns>
|
||||
// This method is marked as AllowAnonymous and protected with a secret (linkKey) inside the model for the following reasons
|
||||
// - when a js client uses the fetch api (or old ajax requests) they can send a bearer token
|
||||
// but since this method returns a redirect (after middleware intervenes) to another domain
|
||||
|
||||
@@ -14,8 +14,8 @@ public static partial class UmbracoApplicationBuilderExtensions
|
||||
/// <summary>
|
||||
/// Adds all required middleware to run the back office
|
||||
/// </summary>
|
||||
/// <param name="builder"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="builder">The Umbraco application builder context.</param>
|
||||
/// <returns>The builder for chaining.</returns>
|
||||
public static IUmbracoApplicationBuilderContext UseBackOffice(this IUmbracoApplicationBuilderContext builder)
|
||||
{
|
||||
builder.AppBuilder.UseMiddleware<BackOfficeExternalLoginProviderErrorMiddleware>();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Umbraco.Cms.Api.Management.ViewModels.UserGroup;
|
||||
using Umbraco.Cms.Api.Management.ViewModels.UserGroup;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Models.Membership;
|
||||
using Umbraco.Cms.Core.Services.OperationStatus;
|
||||
@@ -13,28 +13,28 @@ public interface IUserGroupPresentationFactory
|
||||
/// <summary>
|
||||
/// Creates a <see cref="UserGroupResponseModel"/> based on a <see cref="UserGroup"/>
|
||||
/// </summary>
|
||||
/// <param name="userGroup"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="userGroup">The user group to create a response model from.</param>
|
||||
/// <returns>The user group response model.</returns>
|
||||
Task<UserGroupResponseModel> CreateAsync(IUserGroup userGroup);
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="UserGroupResponseModel"/> base on multiple <see cref="UserGroup"/>
|
||||
/// </summary>
|
||||
/// <param name="userGroups"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="userGroups">The user groups to create response models from.</param>
|
||||
/// <returns>The user group response models.</returns>
|
||||
Task<IEnumerable<UserGroupResponseModel>> CreateMultipleAsync(IEnumerable<IUserGroup> userGroups);
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="UserGroupResponseModel"/> base on multiple <see cref="UserGroup"/>
|
||||
/// </summary>
|
||||
/// <param name="userGroups"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="userGroups">The read-only user groups to create response models from.</param>
|
||||
/// <returns>The user group response models.</returns>
|
||||
Task<IEnumerable<UserGroupResponseModel>> CreateMultipleAsync(IEnumerable<IReadOnlyUserGroup> userGroups);
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="IUserGroup"/> based on a <see cref="CreateUserGroupRequestModel"/>
|
||||
/// </summary>
|
||||
/// <param name="requestModel"></param>
|
||||
/// <param name="requestModel">The request model containing the user group data.</param>
|
||||
/// <returns>An attempt indicating if the operation was a success as well as a more detailed <see cref="UserGroupOperationStatus"/>.</returns>
|
||||
Task<Attempt<IUserGroup, UserGroupOperationStatus>> CreateAsync(CreateUserGroupRequestModel requestModel);
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@ public class BackOfficeAuthenticationBuilder : AuthenticationBuilder
|
||||
/// </summary>
|
||||
/// <typeparam name="TOptions"></typeparam>
|
||||
/// <typeparam name="THandler"></typeparam>
|
||||
/// <param name="authenticationScheme"></param>
|
||||
/// <param name="displayName"></param>
|
||||
/// <param name="configureOptions"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="authenticationScheme">The authentication scheme name.</param>
|
||||
/// <param name="displayName">The display name for the scheme.</param>
|
||||
/// <param name="configureOptions">Optional configuration for the scheme options.</param>
|
||||
/// <returns>The authentication builder for chaining.</returns>
|
||||
public override AuthenticationBuilder AddRemoteScheme<TOptions, THandler>(
|
||||
string authenticationScheme,
|
||||
string? displayName,
|
||||
|
||||
@@ -14,9 +14,9 @@ public class BackOfficeExternalLoginsBuilder
|
||||
/// <summary>
|
||||
/// Add a back office login provider with options
|
||||
/// </summary>
|
||||
/// <param name="loginProviderOptions"></param>
|
||||
/// <param name="build"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="loginProviderOptions">Optional configuration for the login provider.</param>
|
||||
/// <param name="build">The builder action to configure the authentication scheme.</param>
|
||||
/// <returns>The builder for chaining.</returns>
|
||||
public BackOfficeExternalLoginsBuilder AddBackOfficeLogin(
|
||||
Action<BackOfficeAuthenticationBuilder> build,
|
||||
Action<BackOfficeExternalLoginProviderOptions>? loginProviderOptions = null)
|
||||
|
||||
@@ -44,9 +44,9 @@ internal sealed class BackOfficeSecureDataFormat : ISecureDataFormat<Authenticat
|
||||
/// <summary>
|
||||
/// Un-protects the cookie
|
||||
/// </summary>
|
||||
/// <param name="protectedText"></param>
|
||||
/// <param name="purpose"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="protectedText">The protected cookie text to unprotect.</param>
|
||||
/// <param name="purpose">The purpose string used for protection.</param>
|
||||
/// <returns>The authentication ticket, or null if unprotection fails.</returns>
|
||||
public AuthenticationTicket? Unprotect(string? protectedText, string? purpose)
|
||||
{
|
||||
AuthenticationTicket? decrypt;
|
||||
|
||||
@@ -61,10 +61,10 @@ public class BackOfficeSignInManager : UmbracoSignInManager<BackOfficeIdentityUs
|
||||
/// <summary>
|
||||
/// Custom ExternalLoginSignInAsync overload for handling external sign in with auto-linking
|
||||
/// </summary>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <param name="isPersistent"></param>
|
||||
/// <param name="bypassTwoFactor"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="loginInfo">The external login information.</param>
|
||||
/// <param name="isPersistent">Whether the sign-in should be persistent.</param>
|
||||
/// <param name="bypassTwoFactor">Whether to bypass two-factor authentication.</param>
|
||||
/// <returns>The sign-in result.</returns>
|
||||
public async Task<SignInResult> ExternalLoginSignInAsync(ExternalLoginInfo loginInfo, bool isPersistent, bool bypassTwoFactor = false)
|
||||
{
|
||||
// borrowed from https://github.com/dotnet/aspnetcore/blob/master/src/Identity/Core/src/SignInManager.cs
|
||||
@@ -129,10 +129,10 @@ public class BackOfficeSignInManager : UmbracoSignInManager<BackOfficeIdentityUs
|
||||
/// <summary>
|
||||
/// Overridden to deal with events/notificiations
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="username"></param>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="user">The user being signed in.</param>
|
||||
/// <param name="username">The username.</param>
|
||||
/// <param name="result">The sign-in result from the base implementation.</param>
|
||||
/// <returns>The sign-in result after handling notifications.</returns>
|
||||
protected override async Task<SignInResult> HandleSignIn(BackOfficeIdentityUser? user, string? username, SignInResult result)
|
||||
{
|
||||
result = await base.HandleSignIn(user, username, result);
|
||||
@@ -166,9 +166,9 @@ public class BackOfficeSignInManager : UmbracoSignInManager<BackOfficeIdentityUs
|
||||
/// <summary>
|
||||
/// Used for auto linking/creating user accounts for external logins
|
||||
/// </summary>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <param name="autoLinkOptions"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="loginInfo">The external login information.</param>
|
||||
/// <param name="autoLinkOptions">The auto-link options for external accounts.</param>
|
||||
/// <returns>The sign-in result.</returns>
|
||||
private async Task<SignInResult> AutoLinkAndSignInExternalAccount(ExternalLoginInfo loginInfo, ExternalSignInAutoLinkOptions? autoLinkOptions)
|
||||
{
|
||||
// If there are no autolink options then the attempt is failed (user does not exist)
|
||||
|
||||
@@ -8,20 +8,20 @@ public interface IBackOfficeExternalLoginProviders
|
||||
/// <summary>
|
||||
/// Get the <see cref="BackOfficeExternalLoginProvider" /> for the specified scheme
|
||||
/// </summary>
|
||||
/// <param name="authenticationType"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="authenticationType">The authentication scheme name.</param>
|
||||
/// <returns>The external login provider scheme, or null if not found.</returns>
|
||||
Task<BackOfficeExternaLoginProviderScheme?> GetAsync(string authenticationType);
|
||||
|
||||
/// <summary>
|
||||
/// Get all registered <see cref="BackOfficeExternalLoginProvider" />
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns>All registered back office external login provider schemes.</returns>
|
||||
Task<IEnumerable<BackOfficeExternaLoginProviderScheme>> GetBackOfficeProvidersAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if there is any external provider that has the Deny Local Login option configured
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns>True if any provider has deny local login configured.</returns>
|
||||
bool HasDenyLocalLogin();
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -8,6 +8,9 @@ using Umbraco.Cms.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.BackgroundJobs
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides methods to calculate delay intervals for scheduling background jobs.
|
||||
/// </summary>
|
||||
public class DelayCalculator
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -2,6 +2,7 @@ using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.BackgroundJobs;
|
||||
|
||||
/// <summary>
|
||||
/// A recurring background job
|
||||
/// </summary>
|
||||
@@ -21,10 +22,20 @@ public interface IRecurringBackgroundJob
|
||||
/// </summary>
|
||||
TimeSpan Delay { get => DefaultDelay; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the server roles for which this recurring background job is intended.
|
||||
/// </summary>
|
||||
ServerRole[] ServerRoles { get => DefaultServerRoles; }
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the <see cref="Period"/> value has changed.
|
||||
/// </summary>
|
||||
event EventHandler PeriodChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Executes the logic associated with the recurring background job asynchronously.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous execution of the background job.</returns>
|
||||
Task RunJobAsync();
|
||||
}
|
||||
|
||||
|
||||
+10
@@ -42,6 +42,13 @@ internal class CacheInstructionsPruningJob : IDistributedBackgroundJob
|
||||
_lastSyncedManager = lastSyncedManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CacheInstructionsPruningJob"/> class, responsible for pruning cache instructions in a distributed environment.
|
||||
/// </summary>
|
||||
/// <param name="globalSettings">The global settings for the Umbraco application.</param>
|
||||
/// <param name="cacheInstructionRepository">The repository used to access and manage cache instructions.</param>
|
||||
/// <param name="scopeProvider">The provider for managing database transaction scopes.</param>
|
||||
/// <param name="timeProvider">The provider used to obtain the current time.</param>
|
||||
[Obsolete("Use the constructor with ILastSyncedManager parameter instead. Scheduled for removal in Umbraco 18.")]
|
||||
public CacheInstructionsPruningJob(
|
||||
IOptions<GlobalSettings> globalSettings,
|
||||
@@ -57,6 +64,9 @@ internal class CacheInstructionsPruningJob : IDistributedBackgroundJob
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the display name of the CacheInstructionsPruningJob, used to identify this background job.
|
||||
/// </summary>
|
||||
public string Name => "CacheInstructionsPruningJob";
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
+2
@@ -21,6 +21,8 @@ internal class TemporaryFileCleanupJob : IDistributedBackgroundJob
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TemporaryFileCleanupJob" /> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger used to record job execution details and errors.</param>
|
||||
/// <param name="temporaryFileService">The service responsible for managing temporary files.</param>
|
||||
public TemporaryFileCleanupJob(
|
||||
ILogger<TemporaryFileCleanupJob> logger,
|
||||
ITemporaryFileService temporaryFileService)
|
||||
|
||||
@@ -9,15 +9,31 @@ using Umbraco.Cms.Core.Telemetry.Models;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.BackgroundJobs.Jobs;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a background job that collects and reports information about the current Umbraco site, typically for analytics, diagnostics, or telemetry purposes.
|
||||
/// </summary>
|
||||
public class ReportSiteJob : IRecurringBackgroundJob
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the period at which the report site job runs.
|
||||
/// </summary>
|
||||
public TimeSpan Period => TimeSpan.FromDays(1);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the initial delay after application start-up before the first execution of the <see cref="ReportSiteJob"/>.
|
||||
/// The delay is set to 5 minutes.
|
||||
/// </summary>
|
||||
public TimeSpan Delay => TimeSpan.FromMinutes(5);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an array containing all possible values of the <see cref="ServerRole"/> enumeration.
|
||||
/// </summary>
|
||||
public ServerRole[] ServerRoles => Enum.GetValues<ServerRole>();
|
||||
|
||||
// No-op event as the period never changes on this job
|
||||
/// <summary>
|
||||
/// Event that is triggered when the reporting period for the site job is changed.
|
||||
/// </summary>
|
||||
/// <remarks>No-op event as the period never changes on this job</remarks>
|
||||
public event EventHandler PeriodChanged
|
||||
{
|
||||
add { }
|
||||
@@ -29,6 +45,13 @@ public class ReportSiteJob : IRecurringBackgroundJob
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReportSiteJob"/> class, responsible for reporting site telemetry data.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger used to record job execution details and errors.</param>
|
||||
/// <param name="telemetryService">The service used to collect and provide telemetry data for reporting.</param>
|
||||
/// <param name="jsonSerializer">The serializer used to convert telemetry data to JSON format for transmission.</param>
|
||||
/// <param name="httpClientFactory">The factory used to create HTTP clients for sending telemetry reports.</param>
|
||||
public ReportSiteJob(
|
||||
ILogger<ReportSiteJob> logger,
|
||||
ITelemetryService telemetryService,
|
||||
@@ -42,9 +65,9 @@ public class ReportSiteJob : IRecurringBackgroundJob
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs the background task to send the anonymous ID
|
||||
/// to telemetry service
|
||||
/// Executes the background job that sends the anonymous site ID to the telemetry service.
|
||||
/// </summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
public async Task RunJobAsync()
|
||||
{
|
||||
TelemetryReportData? telemetryReportData = await _telemetryService.GetTelemetryReportDataAsync().ConfigureAwait(false);
|
||||
|
||||
+20
-2
@@ -15,12 +15,25 @@ namespace Umbraco.Cms.Infrastructure.BackgroundJobs.Jobs.ServerRegistration;
|
||||
/// </summary>
|
||||
public class InstructionProcessJob : IRecurringBackgroundJob
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Gets the interval between executions of the instruction process job.
|
||||
/// </summary>
|
||||
public TimeSpan Period { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the delay time before the job is executed. The delay is fixed at one minute.
|
||||
/// </summary>
|
||||
public TimeSpan Delay { get => TimeSpan.FromMinutes(1); }
|
||||
|
||||
/// <summary>
|
||||
/// Gets an array containing all possible values of the <see cref="ServerRole"/> enumeration.
|
||||
/// </summary>
|
||||
public ServerRole[] ServerRoles { get => Enum.GetValues<ServerRole>(); }
|
||||
|
||||
// No-op event as the period never changes on this job
|
||||
/// <summary>
|
||||
/// Event that is raised when the execution period of the <see cref="InstructionProcessJob"/> is changed.
|
||||
/// </summary>
|
||||
/// <remarks>No-op event as the period never changes on this job</remarks>
|
||||
public event EventHandler PeriodChanged { add { } remove { } }
|
||||
|
||||
private readonly ILogger<InstructionProcessJob> _logger;
|
||||
@@ -43,6 +56,11 @@ public class InstructionProcessJob : IRecurringBackgroundJob
|
||||
Period = globalSettings.Value.DatabaseServerMessenger.TimeBetweenSyncOperations;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the instruction processing job asynchronously by synchronizing messages using the messenger service.
|
||||
/// Logs an error if the synchronization fails, but always completes the task.
|
||||
/// </summary>
|
||||
/// <returns>A completed task representing the asynchronous operation.</returns>
|
||||
public Task RunJobAsync()
|
||||
{
|
||||
try
|
||||
|
||||
+20
-1
@@ -17,13 +17,27 @@ namespace Umbraco.Cms.Infrastructure.BackgroundJobs.Jobs.ServerRegistration;
|
||||
/// </summary>
|
||||
public class TouchServerJob : IRecurringBackgroundJob
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the period that defines how often the server should be touched.
|
||||
/// </summary>
|
||||
public TimeSpan Period { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the initial delay of 15 seconds after application start-up before the first execution of the touch server job.
|
||||
/// </summary>
|
||||
public TimeSpan Delay { get => TimeSpan.FromSeconds(15); }
|
||||
|
||||
// Runs on all servers
|
||||
/// <summary>
|
||||
/// Gets all server roles on which this job runs. This property returns every possible <see cref="ServerRole"/> value, indicating the job runs on all server roles.
|
||||
/// </summary>
|
||||
/// <remarks>Runs on all servers</remarks>
|
||||
public ServerRole[] ServerRoles { get => Enum.GetValues<ServerRole>(); }
|
||||
|
||||
private event EventHandler? _periodChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the period of the TouchServerJob changes.
|
||||
/// </summary>
|
||||
public event EventHandler PeriodChanged
|
||||
{
|
||||
add { _periodChanged += value; }
|
||||
@@ -69,6 +83,11 @@ public class TouchServerJob : IRecurringBackgroundJob
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the job that updates the server registration by touching the server record in the database.
|
||||
/// This keeps the server's registration active and ensures its status remains current.
|
||||
/// </summary>
|
||||
/// <returns>A completed task when the job has finished running.</returns>
|
||||
public Task RunJobAsync()
|
||||
{
|
||||
|
||||
|
||||
@@ -17,12 +17,21 @@ namespace Umbraco.Cms.Infrastructure.BackgroundJobs.Jobs;
|
||||
/// </remarks>
|
||||
public class TempFileCleanupJob : IRecurringBackgroundJob
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the time interval between each execution of the temporary file cleanup job.
|
||||
/// </summary>
|
||||
public TimeSpan Period { get => TimeSpan.FromMinutes(60); }
|
||||
|
||||
// Runs on all servers
|
||||
/// <summary>
|
||||
/// Gets the server roles on which this job runs. This job is configured to run on all server roles.
|
||||
/// </summary>
|
||||
/// <remarks>Runs on all servers</remarks>
|
||||
public ServerRole[] ServerRoles { get => Enum.GetValues<ServerRole>(); }
|
||||
|
||||
// No-op event as the period never changes on this job
|
||||
/// <summary>
|
||||
/// Occurs when the period of the TempFileCleanupJob changes.
|
||||
/// </summary>
|
||||
/// <remarks>No-op event as the period never changes on this job</remarks>
|
||||
public event EventHandler PeriodChanged { add { } remove { } }
|
||||
|
||||
private readonly TimeSpan _age = TimeSpan.FromDays(1);
|
||||
@@ -43,6 +52,10 @@ public class TempFileCleanupJob : IRecurringBackgroundJob
|
||||
_tempFolders = _ioHelper.GetTempFolders();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously executes the cleanup of temporary files in the configured temporary folders.
|
||||
/// </summary>
|
||||
/// <returns>A task that represents the asynchronous cleanup operation.</returns>
|
||||
public Task RunJobAsync()
|
||||
{
|
||||
foreach (DirectoryInfo folder in _tempFolders)
|
||||
|
||||
@@ -14,8 +14,16 @@ using Umbraco.Cms.Infrastructure.HostedServices;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.BackgroundJobs;
|
||||
|
||||
/// <summary>
|
||||
/// Hosted service responsible for scheduling and executing recurring background jobs within the application.
|
||||
/// </summary>
|
||||
public static class RecurringBackgroundJobHostedService
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a factory function that produces hosted services for recurring background jobs.
|
||||
/// </summary>
|
||||
/// <param name="serviceProvider">The service provider used to create hosted service instances.</param>
|
||||
/// <returns>A function that takes an <see cref="IRecurringBackgroundJob"/> and returns an <see cref="IHostedService"/>.</returns>
|
||||
public static Func<IRecurringBackgroundJob, IHostedService> CreateHostedServiceFactory(IServiceProvider serviceProvider) =>
|
||||
(IRecurringBackgroundJob job) =>
|
||||
{
|
||||
@@ -39,6 +47,15 @@ public class RecurringBackgroundJobHostedService<TJob> : RecurringHostedServiceB
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
private readonly IRecurringBackgroundJob _job;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RecurringBackgroundJobHostedService{TJob}"/> class, which manages the execution of a recurring background job.
|
||||
/// </summary>
|
||||
/// <param name="runtimeState">Provides information about the current runtime state of the Umbraco application.</param>
|
||||
/// <param name="logger">The logger used to record diagnostic and operational information for this hosted service.</param>
|
||||
/// <param name="mainDom">The main domain instance responsible for coordinating single-instance operations across multiple application domains.</param>
|
||||
/// <param name="serverRoleAccessor">Determines the current server's role in a multi-server environment.</param>
|
||||
/// <param name="eventAggregator">Handles the publishing and subscribing of application events.</param>
|
||||
/// <param name="job">The recurring background job instance to be managed and executed by this service.</param>
|
||||
public RecurringBackgroundJobHostedService(
|
||||
IRuntimeState runtimeState,
|
||||
ILogger<RecurringBackgroundJobHostedService<TJob>> logger,
|
||||
@@ -104,6 +121,13 @@ public class RecurringBackgroundJobHostedService<TJob> : RecurringHostedServiceB
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously starts the recurring background job and publishes notifications before and after the job is started.
|
||||
/// This method first publishes a <see cref="Notifications.RecurringBackgroundJobStartingNotification"/> prior to starting the job,
|
||||
/// then calls the base implementation to start the job, and finally publishes a <see cref="Notifications.RecurringBackgroundJobStartedNotification"/>.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">A token to monitor for cancellation requests.</param>
|
||||
/// <returns>A task that represents the asynchronous start operation.</returns>
|
||||
public override async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var startingNotification = new Notifications.RecurringBackgroundJobStartingNotification(_job, new EventMessages());
|
||||
@@ -115,6 +139,11 @@ public class RecurringBackgroundJobHostedService<TJob> : RecurringHostedServiceB
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously stops the recurring background job service, publishing notifications before and after stopping.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">A token to monitor for cancellation requests.</param>
|
||||
/// <returns>A task that represents the asynchronous stop operation.</returns>
|
||||
public override async Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var stoppingNotification = new Notifications.RecurringBackgroundJobStoppingNotification(_job, new EventMessages());
|
||||
|
||||
+22
@@ -14,6 +14,12 @@ public class RecurringBackgroundJobHostedServiceRunner : IHostedService
|
||||
private readonly List<NamedServiceJob> _hostedServices = new();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RecurringBackgroundJobHostedServiceRunner"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">An <see cref="ILogger{RecurringBackgroundJobHostedServiceRunner}"/> used for logging within the runner.</param>
|
||||
/// <param name="jobs">A collection of <see cref="IRecurringBackgroundJob"/> instances to be managed by the runner.</param>
|
||||
/// <param name="jobFactory">A factory function that creates an <see cref="IHostedService"/> for each <see cref="IRecurringBackgroundJob"/>.</param>
|
||||
public RecurringBackgroundJobHostedServiceRunner(
|
||||
ILogger<RecurringBackgroundJobHostedServiceRunner> logger,
|
||||
IEnumerable<IRecurringBackgroundJob> jobs,
|
||||
@@ -52,6 +58,11 @@ public class RecurringBackgroundJobHostedServiceRunner : IHostedService
|
||||
_logger.LogInformation("Completed starting recurring background jobs hosted services");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously stops all recurring background job hosted services managed by this runner.
|
||||
/// </summary>
|
||||
/// <param name="stoppingToken">A <see cref="CancellationToken"/> that can be used to cancel the stop operation.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous stop operation.</returns>
|
||||
public async Task StopAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
_logger.LogInformation("Stopping recurring background jobs hosted services");
|
||||
@@ -74,14 +85,25 @@ public class RecurringBackgroundJobHostedServiceRunner : IHostedService
|
||||
|
||||
private sealed class NamedServiceJob
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NamedServiceJob"/> class using the specified job name and hosted service instance.
|
||||
/// </summary>
|
||||
/// <param name="name">The unique name identifying the job.</param>
|
||||
/// <param name="hostedService">The <see cref="IHostedService"/> instance to be executed as the background job.</param>
|
||||
public NamedServiceJob(string name, IHostedService hostedService)
|
||||
{
|
||||
Name = name;
|
||||
HostedService = hostedService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unique name that identifies this background job.
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hosted service instance associated with the named service job.
|
||||
/// </summary>
|
||||
public IHostedService HostedService { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,8 @@ public sealed class DatabaseServerMessengerNotificationHandler :
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear the batch on end request
|
||||
/// Handles the end of an Umbraco request by sending the batch of distributed cache instructions.
|
||||
/// </summary>
|
||||
/// <param name="notification">The notification instance signaling the end of an Umbraco request.</param>
|
||||
public void Handle(UmbracoRequestEndNotification notification) => _messenger?.SendMessages();
|
||||
}
|
||||
|
||||
@@ -27,6 +27,14 @@ public class DefaultRepositoryCachePolicy<TEntity, TId> : RepositoryCachePolicyB
|
||||
private static readonly TEntity[] _emptyEntities = new TEntity[0]; // const
|
||||
private readonly RepositoryCachePolicyOptions _options;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DefaultRepositoryCachePolicy{TEntity, TId}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="cache">The application-level policy cache used for storing repository items.</param>
|
||||
/// <param name="scopeAccessor">Provides access to the current scope.</param>
|
||||
/// <param name="options">The options that configure repository cache policy behavior.</param>
|
||||
/// <param name="repositoryCacheVersionService">Service for managing repository cache versions.</param>
|
||||
/// <param name="cacheSyncService">Service responsible for synchronizing cache across instances.</param>
|
||||
public DefaultRepositoryCachePolicy(
|
||||
IAppPolicyCache cache,
|
||||
IScopeAccessor scopeAccessor,
|
||||
@@ -36,6 +44,12 @@ public class DefaultRepositoryCachePolicy<TEntity, TId> : RepositoryCachePolicyB
|
||||
: base(cache, scopeAccessor, repositoryCacheVersionService, cacheSyncService) =>
|
||||
_options = options ?? throw new ArgumentNullException(nameof(options));
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DefaultRepositoryCachePolicy{TEntity, TId}"/> class, which manages caching for repository entities.
|
||||
/// </summary>
|
||||
/// <param name="cache">The application-level policy cache used for storing cached items.</param>
|
||||
/// <param name="scopeAccessor">Provides access to the current scope for cache operations.</param>
|
||||
/// <param name="options">The configuration options for the repository cache policy.</param>
|
||||
[Obsolete("Please use the constructor with all parameters. Scheduled for removal in Umbraco 18.")]
|
||||
public DefaultRepositoryCachePolicy(
|
||||
IAppPolicyCache cache,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Runtime.Versioning;
|
||||
using System.Runtime.Versioning;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Umbraco.Cms.Core.DependencyInjection;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
@@ -7,8 +7,20 @@ using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a cache policy that determines how usernames are cached in the member repository.
|
||||
/// This policy controls the caching behavior for member username lookups to improve performance and consistency.
|
||||
/// </summary>
|
||||
public class MemberRepositoryUsernameCachePolicy : DefaultRepositoryCachePolicy<IMember, string>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MemberRepositoryUsernameCachePolicy"/> class, which defines the caching policy for member repository lookups by username.
|
||||
/// </summary>
|
||||
/// <param name="cache">The application-level policy cache used for storing cached member data.</param>
|
||||
/// <param name="scopeAccessor">Provides access to the current scope for cache operations.</param>
|
||||
/// <param name="options">Configuration options for the repository cache policy.</param>
|
||||
/// <param name="repositoryCacheVersionService">Service for managing cache versioning within the repository.</param>
|
||||
/// <param name="cacheSyncService">Service responsible for synchronizing cache across distributed environments.</param>
|
||||
public MemberRepositoryUsernameCachePolicy(
|
||||
IAppPolicyCache cache,
|
||||
IScopeAccessor scopeAccessor,
|
||||
@@ -24,6 +36,12 @@ public class MemberRepositoryUsernameCachePolicy : DefaultRepositoryCachePolicy<
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MemberRepositoryUsernameCachePolicy"/> class.
|
||||
/// </summary>
|
||||
/// <param name="cache">The <see cref="IAppPolicyCache"/> instance used for caching member data by username.</param>
|
||||
/// <param name="scopeAccessor">The <see cref="IScopeAccessor"/> used to manage the current scope for cache operations.</param>
|
||||
/// <param name="options">The <see cref="RepositoryCachePolicyOptions"/> that configure cache policy behavior for the repository.</param>
|
||||
[Obsolete("Please use the constructor with all parameters. Scheduled for removal in Umbraco 18.")]
|
||||
public MemberRepositoryUsernameCachePolicy(
|
||||
IAppPolicyCache cache,
|
||||
@@ -38,6 +56,14 @@ public class MemberRepositoryUsernameCachePolicy : DefaultRepositoryCachePolicy<
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a member by username, first attempting to get it from the cache. If not present, fetches the member using the provided delegate and caches the result.
|
||||
/// </summary>
|
||||
/// <param name="key">A prefix used to construct the cache key for the member.</param>
|
||||
/// <param name="username">The username of the member to retrieve.</param>
|
||||
/// <param name="performGetByUsername">A delegate to fetch the member by username if it is not found in the cache.</param>
|
||||
/// <param name="performGetAll">A delegate to fetch all members. This parameter is required by the interface but is not used in this method.</param>
|
||||
/// <returns>The <see cref="IMember"/> matching the specified username if found; otherwise, <c>null</c>.</returns>
|
||||
public IMember? GetByUserName(string key, string? username, Func<string?, IMember?> performGetByUsername, Func<string[]?, IEnumerable<IMember>?> performGetAll)
|
||||
{
|
||||
EnsureCacheIsSynced();
|
||||
@@ -61,6 +87,14 @@ public class MemberRepositoryUsernameCachePolicy : DefaultRepositoryCachePolicy<
|
||||
return entity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the cache entry for a member associated with the specified user name and key.
|
||||
/// </summary>
|
||||
/// <param name="key">A string used as part of the cache key to identify the cache entry.</param>
|
||||
/// <param name="username">The user name of the member whose cache entry should be removed. Can be <c>null</c>.</param>
|
||||
/// <remarks>
|
||||
/// This method also registers a cache change notification for other servers in a distributed environment.
|
||||
/// </remarks>
|
||||
public void DeleteByUserName(string key, string? username)
|
||||
{
|
||||
// We've removed an entity, register cache change for other servers.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
@@ -11,14 +11,28 @@ internal sealed class BlockEditorElementTypeCache : IBlockEditorElementTypeCache
|
||||
private readonly AppCaches _appCaches;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Core.Cache.PropertyEditors.BlockEditorElementTypeCache"/> class.
|
||||
/// </summary>
|
||||
/// <param name="contentTypeService">The service used to manage and retrieve content types.</param>
|
||||
/// <param name="appCaches">The application-level cache manager used for caching element type data.</param>
|
||||
public BlockEditorElementTypeCache(IContentTypeService contentTypeService, AppCaches appCaches)
|
||||
{
|
||||
_contentTypeService = contentTypeService;
|
||||
_appCaches = appCaches;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all content types whose unique identifiers are contained in the specified collection of keys.
|
||||
/// </summary>
|
||||
/// <param name="keys">A collection of <see cref="System.Guid"/> values representing the unique identifiers of the content types to retrieve.</param>
|
||||
/// <returns>An <see cref="IEnumerable{IContentType}"/> containing the content types that match the provided keys.</returns>
|
||||
public IEnumerable<IContentType> GetMany(IEnumerable<Guid> keys) => GetAll().Where(elementType => keys.Contains(elementType.Key));
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all content types that are configured as element types for use in the block editor.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="IEnumerable{IContentType}"/> containing all element content types available to the block editor.</returns>
|
||||
public IEnumerable<IContentType> GetAll()
|
||||
{
|
||||
// TODO: make this less dumb; don't fetch all elements, only fetch the items that aren't yet in the cache and amend the cache as more elements are loaded
|
||||
@@ -32,5 +46,8 @@ internal sealed class BlockEditorElementTypeCache : IBlockEditorElementTypeCache
|
||||
return cachedElements;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears all cached block editor element types from the request cache.
|
||||
/// </summary>
|
||||
public void ClearAll() => _appCaches.RequestCache.Remove(CacheKey);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,28 @@
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache.PropertyEditors;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a cache responsible for storing and retrieving element types used by the block editor in Umbraco.
|
||||
/// This cache helps optimize access to element type definitions, improving performance when working with block editor data structures.
|
||||
/// </summary>
|
||||
public interface IBlockEditorElementTypeCache
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves the content types corresponding to the specified keys.
|
||||
/// </summary>
|
||||
/// <param name="keys">A collection of unique identifiers (keys) for the content types to retrieve.</param>
|
||||
/// <returns>An enumerable collection of <see cref="IContentType"/> instances that match the provided keys. Only content types with matching keys are returned.</returns>
|
||||
IEnumerable<IContentType> GetMany(IEnumerable<Guid> keys);
|
||||
|
||||
/// <summary>
|
||||
/// Gets all block editor element content types.
|
||||
/// </summary>
|
||||
/// <returns>An enumerable of all <see cref="Umbraco.Cms.Core.Models.IContentType"/> instances.</returns>
|
||||
IEnumerable<IContentType> GetAll();
|
||||
|
||||
/// <summary>
|
||||
/// Clears all cached block editor element types.
|
||||
/// </summary>
|
||||
void ClearAll() { }
|
||||
}
|
||||
|
||||
@@ -23,6 +23,14 @@ namespace Umbraco.Cms.Core.Cache;
|
||||
internal sealed class SingleItemsOnlyRepositoryCachePolicy<TEntity, TId> : DefaultRepositoryCachePolicy<TEntity, TId>
|
||||
where TEntity : class, IEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SingleItemsOnlyRepositoryCachePolicy{TEntity, TId}"/> class, which manages caching for repository items where only single items are cached at a time.
|
||||
/// </summary>
|
||||
/// <param name="cache">The application-level policy cache used for storing cached items.</param>
|
||||
/// <param name="scopeAccessor">Provides access to the current scope for cache operations.</param>
|
||||
/// <param name="options">Configuration options for the repository cache policy.</param>
|
||||
/// <param name="repositoryCacheVersionService">Service for managing cache versioning within the repository.</param>
|
||||
/// <param name="cacheSyncService">Service responsible for synchronizing cache across distributed environments.</param>
|
||||
public SingleItemsOnlyRepositoryCachePolicy(
|
||||
IAppPolicyCache cache,
|
||||
IScopeAccessor scopeAccessor,
|
||||
@@ -38,6 +46,12 @@ internal sealed class SingleItemsOnlyRepositoryCachePolicy<TEntity, TId> : Defau
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Core.Cache.SingleItemsOnlyRepositoryCachePolicy{TEntity, TId}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="cache">The <see cref="IAppPolicyCache"/> used for caching repository items.</param>
|
||||
/// <param name="scopeAccessor">The <see cref="IScopeAccessor"/> that provides access to the current scope.</param>
|
||||
/// <param name="options">The <see cref="RepositoryCachePolicyOptions"/> that configure the cache policy behavior.</param>
|
||||
[Obsolete("Please use the constructor with all parameters. Scheduled for removal in Umbraco 18.")]
|
||||
public SingleItemsOnlyRepositoryCachePolicy(IAppPolicyCache cache, IScopeAccessor scopeAccessor, RepositoryCachePolicyOptions options)
|
||||
: this(
|
||||
|
||||
@@ -25,6 +25,11 @@ internal sealed class JsonConfigManipulator : IConfigManipulator
|
||||
private readonly ILogger<JsonConfigManipulator> _logger;
|
||||
private readonly SemaphoreSlim _lock = new(1, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="JsonConfigManipulator"/> class.
|
||||
/// </summary>
|
||||
/// <param name="configuration">The <see cref="IConfiguration"/> instance containing configuration settings.</param>
|
||||
/// <param name="logger">The <see cref="ILogger{JsonConfigManipulator}"/> instance used for logging operations.</param>
|
||||
public JsonConfigManipulator(IConfiguration configuration, ILogger<JsonConfigManipulator> logger)
|
||||
{
|
||||
_configuration = configuration;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Umbraco.Cms.Core.DeliveryApi;
|
||||
using Umbraco.Cms.Core.DeliveryApi;
|
||||
using Umbraco.Cms.Core.Models.DeliveryApi;
|
||||
using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
|
||||
@@ -6,6 +6,11 @@ namespace Umbraco.Cms.Infrastructure.DeliveryApi;
|
||||
|
||||
internal sealed class ApiMediaWithCropsBuilder : ApiMediaWithCropsBuilderBase<IApiMediaWithCrops>, IApiMediaWithCropsBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiMediaWithCropsBuilder"/> class, which is responsible for building API media objects with crop data.
|
||||
/// </summary>
|
||||
/// <param name="apiMediaBuilder">An instance of <see cref="IApiMediaBuilder"/> used to construct API media representations.</param>
|
||||
/// <param name="publishedValueFallback">An instance of <see cref="IPublishedValueFallback"/> used to provide fallback values for published content properties.</param>
|
||||
public ApiMediaWithCropsBuilder(IApiMediaBuilder apiMediaBuilder, IPublishedValueFallback publishedValueFallback)
|
||||
: base(apiMediaBuilder, publishedValueFallback)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.DeliveryApi;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Models.DeliveryApi;
|
||||
@@ -26,6 +26,12 @@ internal abstract class ApiMediaWithCropsBuilderBase<T>
|
||||
ImageFocalPoint? focalPoint,
|
||||
IEnumerable<ImageCrop>? crops);
|
||||
|
||||
/// <summary>
|
||||
/// Builds an instance of <typeparamref name="T" /> from the specified <see cref="MediaWithCrops" />.
|
||||
/// Merges crop and focal point data from both the media item and its local values, giving precedence to local values in case of conflicts.
|
||||
/// </summary>
|
||||
/// <param name="media">The <see cref="MediaWithCrops" /> instance containing the media content and crop information.</param>
|
||||
/// <returns>An instance of <typeparamref name="T" /> representing the built media with merged crop and focal point data.</returns>
|
||||
public T Build(MediaWithCrops media)
|
||||
{
|
||||
IApiMedia inner = _apiMediaBuilder.Build(media.Content);
|
||||
@@ -41,6 +47,11 @@ internal abstract class ApiMediaWithCropsBuilderBase<T>
|
||||
return Create(media.Content, inner, localCrops.GetImageFocalPoint(), localCrops.GetImageCrops());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds and returns an instance of <typeparamref name="T" /> from the provided <see cref="MediaWithCrops" /> object.
|
||||
/// </summary>
|
||||
/// <param name="media">The <see cref="MediaWithCrops" /> instance containing the media content and crop information to build from.</param>
|
||||
/// <returns>An instance of <typeparamref name="T" /> representing the constructed media with merged crop data.</returns>
|
||||
public T Build(IPublishedContent media)
|
||||
{
|
||||
var mediaWithCrops = new MediaWithCrops(media, _publishedValueFallback, new ImageCropperValue());
|
||||
|
||||
@@ -11,6 +11,13 @@ internal sealed class ApiMediaWithCropsResponseBuilder : ApiMediaWithCropsBuilde
|
||||
private readonly IPublishedMediaCache _mediaCache;
|
||||
private readonly IMediaNavigationQueryService _navigationQueryService;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiMediaWithCropsResponseBuilder"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiMediaBuilder">The builder used to construct API media representations.</param>
|
||||
/// <param name="publishedValueFallback">The service used to provide fallback values for published content properties.</param>
|
||||
/// <param name="mediaCache">The cache used for accessing published media items.</param>
|
||||
/// <param name="navigationQueryService">The service used to query media navigation structures.</param>
|
||||
public ApiMediaWithCropsResponseBuilder(
|
||||
IApiMediaBuilder apiMediaBuilder,
|
||||
IPublishedValueFallback publishedValueFallback,
|
||||
|
||||
@@ -20,6 +20,15 @@ internal sealed class ApiRichTextElementParser : ApiRichTextParserBase, IApiRich
|
||||
private const string TextNodeName = "#text";
|
||||
private const string CommentNodeName = "#comment";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Infrastructure.DeliveryApi.ApiRichTextElementParser"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiContentRouteBuilder">An instance of <see cref="IApiContentRouteBuilder"/> used to build API content routes.</param>
|
||||
/// <param name="mediaUrlProvider">An instance of <see cref="IApiMediaUrlProvider"/> used to provide media URLs.</param>
|
||||
/// <param name="publishedContentCache">An instance of <see cref="IPublishedContentCache"/> for accessing published content.</param>
|
||||
/// <param name="publishedMediaCache">An instance of <see cref="IPublishedMediaCache"/> for accessing published media.</param>
|
||||
/// <param name="apiElementBuilder">An instance of <see cref="IApiElementBuilder"/> used to build API elements.</param>
|
||||
/// <param name="logger">An instance of <see cref="ILogger{ApiRichTextElementParser}"/> used for logging.</param>
|
||||
public ApiRichTextElementParser(
|
||||
IApiContentRouteBuilder apiContentRouteBuilder,
|
||||
IApiMediaUrlProvider mediaUrlProvider,
|
||||
@@ -35,6 +44,14 @@ internal sealed class ApiRichTextElementParser : ApiRichTextParserBase, IApiRich
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to parse the specified HTML string into a rich text element.
|
||||
/// </summary>
|
||||
/// <param name="html">The HTML string to parse as a rich text element.</param>
|
||||
/// <param name="richTextBlockModel">An optional context model used during parsing, or <c>null</c> if not applicable.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="IRichTextElement"/> representing the parsed content if successful; otherwise, <c>null</c> if parsing fails.
|
||||
/// </returns>
|
||||
public IRichTextElement? Parse(string html, RichTextBlockModel? richTextBlockModel)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using HtmlAgilityPack;
|
||||
using HtmlAgilityPack;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.DeliveryApi;
|
||||
@@ -14,6 +14,14 @@ internal sealed class ApiRichTextMarkupParser : ApiRichTextParserBase, IApiRichT
|
||||
private readonly IPublishedMediaCache _publishedMediaCache;
|
||||
private readonly ILogger<ApiRichTextMarkupParser> _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Infrastructure.DeliveryApi.ApiRichTextMarkupParser"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiContentRouteBuilder">The <see cref="IApiContentRouteBuilder"/> used to build API content routes.</param>
|
||||
/// <param name="mediaUrlProvider">The <see cref="IApiMediaUrlProvider"/> used to provide media URLs for the API.</param>
|
||||
/// <param name="publishedContentCache">The <see cref="IPublishedContentCache"/> for accessing published content.</param>
|
||||
/// <param name="publishedMediaCache">The <see cref="IPublishedMediaCache"/> for accessing published media.</param>
|
||||
/// <param name="logger">The <see cref="ILogger{ApiRichTextMarkupParser}"/> instance for logging.</param>
|
||||
public ApiRichTextMarkupParser(
|
||||
IApiContentRouteBuilder apiContentRouteBuilder,
|
||||
IApiMediaUrlProvider mediaUrlProvider,
|
||||
@@ -27,6 +35,11 @@ internal sealed class ApiRichTextMarkupParser : ApiRichTextParserBase, IApiRichT
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses the specified HTML rich text, replacing local links and images with appropriate markup and cleaning up block elements.
|
||||
/// </summary>
|
||||
/// <param name="html">The HTML string containing the rich text to parse and transform.</param>
|
||||
/// <returns>The processed HTML string with local links and images replaced, and block elements cleaned up.</returns>
|
||||
public string Parse(string html)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -1,12 +1,21 @@
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Models.DeliveryApi;
|
||||
using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.DeliveryApi;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a builder for creating API media objects that include crop information.
|
||||
/// </summary>
|
||||
public interface IApiMediaWithCropsBuilder
|
||||
{
|
||||
/// <summary>Builds an <see cref="IApiMediaWithCrops"/> instance from the specified <see cref="Umbraco.Cms.Core.Models.MediaWithCrops"/> media.</summary>
|
||||
/// <param name="media">The media with crops to build from.</param>
|
||||
/// <returns>An <see cref="IApiMediaWithCrops"/> representing the built media with crops.</returns>
|
||||
IApiMediaWithCrops Build(MediaWithCrops media);
|
||||
|
||||
/// <summary>Builds an <see cref="IApiMediaWithCrops"/> instance from the specified <see cref="Umbraco.Cms.Core.Models.IPublishedContent"/> media.</summary>
|
||||
/// <param name="media">The published media content to build from.</param>
|
||||
/// <returns>An <see cref="IApiMediaWithCrops"/> representing the built media with crops.</returns>
|
||||
IApiMediaWithCrops Build(IPublishedContent media);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
using Umbraco.Cms.Core.Models.DeliveryApi;
|
||||
using Umbraco.Cms.Core.Models.DeliveryApi;
|
||||
using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.DeliveryApi;
|
||||
|
||||
/// <summary>
|
||||
/// Provides methods for constructing API responses that include media items along with their crop information.
|
||||
/// </summary>
|
||||
public interface IApiMediaWithCropsResponseBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// Builds a response containing media information and crop data from the specified media content.
|
||||
/// </summary>
|
||||
/// <param name="media">The media content to generate the response from.</param>
|
||||
/// <returns>A response object containing media and crop information.</returns>
|
||||
IApiMediaWithCropsResponse Build(IPublishedContent media);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Umbraco.Cms.Core.DependencyInjection;
|
||||
using Umbraco.Cms.Core.Notifications;
|
||||
using Umbraco.Cms.Core.Services.Navigation;
|
||||
@@ -14,8 +14,10 @@ namespace Umbraco.Cms.Infrastructure.DependencyInjection;
|
||||
public static partial class UmbracoBuilderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Add Umbraco background jobs
|
||||
/// Registers the default set of Umbraco background jobs and related hosted services with the specified builder.
|
||||
/// </summary>
|
||||
/// <param name="builder">The <see cref="IUmbracoBuilder"/> to which background jobs will be added.</param>
|
||||
/// <returns>The same <see cref="IUmbracoBuilder"/> instance so that additional calls can be chained.</returns>
|
||||
public static IUmbracoBuilder AddBackgroundJobs(this IUmbracoBuilder builder)
|
||||
{
|
||||
// Add background jobs
|
||||
|
||||
@@ -12,30 +12,34 @@ namespace Umbraco.Extensions;
|
||||
public static partial class UmbracoBuilderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the mappers collection builder.
|
||||
/// Gets the <see cref="MapperCollectionBuilder"/> for registering and configuring mappers.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder.</param>
|
||||
/// <param name="builder">The Umbraco builder instance.</param>
|
||||
/// <returns>The <see cref="MapperCollectionBuilder"/> instance.</returns>
|
||||
public static MapperCollectionBuilder Mappers(this IUmbracoBuilder builder)
|
||||
=> builder.WithCollectionBuilder<MapperCollectionBuilder>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the NPoco mappers collection builder.
|
||||
/// Gets the collection builder for NPoco mappers.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder.</param>
|
||||
/// <param name="builder">The Umbraco builder instance.</param>
|
||||
/// <returns>An <see cref="NPocoMapperCollectionBuilder"/> for configuring NPoco mappers.</returns>
|
||||
public static NPocoMapperCollectionBuilder NPocoMappers(this IUmbracoBuilder builder)
|
||||
=> builder.WithCollectionBuilder<NPocoMapperCollectionBuilder>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the package migration plans collection builder.
|
||||
/// Gets the collection builder for package migration plans.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder.</param>
|
||||
/// <param name="builder">The Umbraco builder instance.</param>
|
||||
/// <returns>The <see cref="PackageMigrationPlanCollectionBuilder"/> for package migration plans.</returns>
|
||||
public static PackageMigrationPlanCollectionBuilder PackageMigrationPlans(this IUmbracoBuilder builder)
|
||||
=> builder.WithCollectionBuilder<PackageMigrationPlanCollectionBuilder>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the runtime mode validators collection builder.
|
||||
/// Returns the collection builder for runtime mode validators.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder.</param>
|
||||
/// <param name="builder">The Umbraco builder instance.</param>
|
||||
/// <returns>The <see cref="RuntimeModeValidatorCollectionBuilder"/> for configuring runtime mode validators.</returns>
|
||||
public static RuntimeModeValidatorCollectionBuilder RuntimeModeValidators(this IUmbracoBuilder builder)
|
||||
=> builder.WithCollectionBuilder<RuntimeModeValidatorCollectionBuilder>();
|
||||
}
|
||||
|
||||
@@ -72,8 +72,10 @@ namespace Umbraco.Cms.Infrastructure.DependencyInjection;
|
||||
public static partial class UmbracoBuilderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds all core Umbraco services required to run which may be replaced later in the pipeline.
|
||||
/// Registers all core Umbraco services required for the application to run. These services may be replaced later in the pipeline.
|
||||
/// </summary>
|
||||
/// <param name="builder">The <see cref="IUmbracoBuilder"/> to which the core services will be added.</param>
|
||||
/// <returns>The same <see cref="IUmbracoBuilder"/> instance, enabling method chaining.</returns>
|
||||
public static IUmbracoBuilder AddCoreInitialServices(this IUmbracoBuilder builder)
|
||||
{
|
||||
builder
|
||||
@@ -273,6 +275,11 @@ public static partial class UmbracoBuilderExtensions
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the default property index value factories used for indexing property values in Umbraco's search infrastructure.
|
||||
/// </summary>
|
||||
/// <param name="builder">The <see cref="IUmbracoBuilder"/> to add the property index value factories to.</param>
|
||||
/// <returns>The same <see cref="Umbraco.Cms.Core.DependencyInjection.IUmbracoBuilder"/> instance so that multiple calls can be chained.</returns>
|
||||
public static IUmbracoBuilder AddPropertyIndexValueFactories(this IUmbracoBuilder builder)
|
||||
{
|
||||
builder.Services.AddSingleton<IBlockValuePropertyIndexValueFactory, BlockValuePropertyIndexValueFactory>();
|
||||
@@ -345,6 +352,12 @@ public static partial class UmbracoBuilderExtensions
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the default set of core notification handlers required by Umbraco for content, media, member, and other system events.
|
||||
/// This includes handlers for user notifications, content relations, property editors, redirect tracking, distributed cache, and more.
|
||||
/// </summary>
|
||||
/// <param name="builder">The <see cref="IUmbracoBuilder"/> to which the core notification handlers will be added.</param>
|
||||
/// <returns>The same <see cref="IUmbracoBuilder"/> instance, enabling method chaining.</returns>
|
||||
public static IUmbracoBuilder AddCoreNotifications(this IUmbracoBuilder builder)
|
||||
{
|
||||
// add handlers for sending user notifications (i.e. emails)
|
||||
|
||||
@@ -22,11 +22,13 @@ namespace Umbraco.Cms.Infrastructure.DependencyInjection;
|
||||
public static partial class UmbracoBuilderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds distributed cache support
|
||||
/// Adds distributed cache support to the specified <see cref="IUmbracoBuilder"/>.
|
||||
/// </summary>
|
||||
/// <param name="builder">The <see cref="IUmbracoBuilder"/> to which distributed cache support will be added.</param>
|
||||
/// <returns>The <see cref="IUmbracoBuilder"/> instance with distributed cache support enabled.</returns>
|
||||
/// <remarks>
|
||||
/// This is still required for websites that are not load balancing because this ensures that sites hosted
|
||||
/// with managed hosts like IIS/etc... work correctly when AppDomains are running in parallel.
|
||||
/// This is still required for websites that are not load balancing because it ensures that sites hosted
|
||||
/// with managed hosts like IIS and similar environments work correctly when AppDomains are running in parallel.
|
||||
/// </remarks>
|
||||
public static IUmbracoBuilder AddDistributedCache(this IUmbracoBuilder builder)
|
||||
{
|
||||
@@ -50,10 +52,11 @@ public static partial class UmbracoBuilderExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the server registrar.
|
||||
/// Registers the specified <typeparamref name="T"/> as the implementation of <see cref="IServerRoleAccessor"/> in the dependency injection container.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the server registrar.</typeparam>
|
||||
/// <param name="builder">The builder.</param>
|
||||
/// <typeparam name="T">The type of the server registrar to register. Must implement <see cref="IServerRoleAccessor"/>.</typeparam>
|
||||
/// <param name="builder">The Umbraco builder to configure.</param>
|
||||
/// <returns>The same <paramref name="builder"/> instance, to allow for method chaining.</returns>
|
||||
public static IUmbracoBuilder SetServerRegistrar<T>(this IUmbracoBuilder builder)
|
||||
where T : class, IServerRoleAccessor
|
||||
{
|
||||
@@ -62,10 +65,11 @@ public static partial class UmbracoBuilderExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the server registrar.
|
||||
/// Configures the <see cref="IServerRoleAccessor"/> implementation used by the Umbraco builder.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder.</param>
|
||||
/// <param name="factory">A function creating a server registrar.</param>
|
||||
/// <param name="builder">The <see cref="IUmbracoBuilder"/> to configure.</param>
|
||||
/// <param name="factory">A factory function that creates an <see cref="IServerRoleAccessor"/> instance using the provided <see cref="IServiceProvider"/>.</param>
|
||||
/// <returns>The configured <see cref="IUmbracoBuilder"/> instance.</returns>
|
||||
public static IUmbracoBuilder SetServerRegistrar(
|
||||
this IUmbracoBuilder builder,
|
||||
Func<IServiceProvider, IServerRoleAccessor> factory)
|
||||
@@ -79,6 +83,7 @@ public static partial class UmbracoBuilderExtensions
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder.</param>
|
||||
/// <param name="registrar">A server registrar.</param>
|
||||
/// <returns>The builder.</returns>
|
||||
public static IUmbracoBuilder SetServerRegistrar(this IUmbracoBuilder builder, IServerRoleAccessor registrar)
|
||||
{
|
||||
builder.Services.AddUnique(registrar);
|
||||
@@ -98,10 +103,11 @@ public static partial class UmbracoBuilderExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the server messenger.
|
||||
/// Configures the <see cref="IServerMessenger"/> implementation used by the application by registering a factory method.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder.</param>
|
||||
/// <param name="factory">A function creating a server messenger.</param>
|
||||
/// <param name="builder">The <see cref="IUmbracoBuilder"/> used to configure services.</param>
|
||||
/// <param name="factory">A factory function that creates an <see cref="IServerMessenger"/> instance using the provided <see cref="IServiceProvider"/>.</param>
|
||||
/// <returns>The <see cref="IUmbracoBuilder"/> instance for chaining.</returns>
|
||||
public static IUmbracoBuilder SetServerMessenger(
|
||||
this IUmbracoBuilder builder,
|
||||
Func<IServiceProvider, IServerMessenger> factory)
|
||||
@@ -111,10 +117,11 @@ public static partial class UmbracoBuilderExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the server messenger.
|
||||
/// Registers the specified <see cref="IServerMessenger"/> implementation with the Umbraco builder.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder.</param>
|
||||
/// <param name="registrar">A server messenger.</param>
|
||||
/// <param name="builder">The <see cref="IUmbracoBuilder"/> used to configure services.</param>
|
||||
/// <param name="registrar">The <see cref="IServerMessenger"/> implementation to register.</param>
|
||||
/// <returns>The <see cref="IUmbracoBuilder"/> instance for chaining.</returns>
|
||||
public static IUmbracoBuilder SetServerMessenger(this IUmbracoBuilder builder, IServerMessenger registrar)
|
||||
{
|
||||
builder.Services.AddUnique(registrar);
|
||||
|
||||
@@ -20,6 +20,12 @@ namespace Umbraco.Cms.Infrastructure.DependencyInjection;
|
||||
/// </summary>
|
||||
public static partial class UmbracoBuilderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers all Examine search and indexing services, including index populators, index rebuilders, value set builders, and notification handlers, with the Umbraco builder.
|
||||
/// This enables full-text search and indexing capabilities within an Umbraco application.
|
||||
/// </summary>
|
||||
/// <param name="builder">The <see cref="IUmbracoBuilder"/> to configure with Examine services.</param>
|
||||
/// <returns>The configured <see cref="IUmbracoBuilder"/> instance.</returns>
|
||||
public static IUmbracoBuilder AddExamine(this IUmbracoBuilder builder)
|
||||
{
|
||||
builder.Services.AddUnique<IExamineManager, ExamineManager>();
|
||||
|
||||
@@ -11,8 +11,10 @@ namespace Umbraco.Cms.Infrastructure.DependencyInjection;
|
||||
public static partial class UmbracoBuilderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers the core Umbraco mapper definitions
|
||||
/// Registers the core Umbraco mapping profiles and related services.
|
||||
/// </summary>
|
||||
/// <param name="builder">The <see cref="IUmbracoBuilder"/> to configure.</param>
|
||||
/// <returns>The configured <see cref="IUmbracoBuilder"/> instance, enabling method chaining.</returns>
|
||||
public static IUmbracoBuilder AddCoreMappingProfiles(this IUmbracoBuilder builder)
|
||||
{
|
||||
builder.Services.AddUnique<IUmbracoMapper, UmbracoMapper>();
|
||||
|
||||
@@ -15,10 +15,11 @@ namespace Umbraco.Cms.Infrastructure.DependencyInjection;
|
||||
public static partial class UmbracoBuilderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the culture dictionary factory.
|
||||
/// Registers the specified <typeparamref name="T"/> as the implementation of <see cref="ICultureDictionaryFactory"/> in the dependency injection container.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the factory.</typeparam>
|
||||
/// <param name="builder">The builder.</param>
|
||||
/// <typeparam name="T">The type of the factory to register. Must implement <see cref="ICultureDictionaryFactory"/>.</typeparam>
|
||||
/// <param name="builder">The Umbraco builder to configure.</param>
|
||||
/// <returns>The same <paramref name="builder"/> instance so that additional calls can be chained.</returns>
|
||||
public static IUmbracoBuilder SetCultureDictionaryFactory<T>(this IUmbracoBuilder builder)
|
||||
where T : class, ICultureDictionaryFactory
|
||||
{
|
||||
@@ -40,10 +41,11 @@ public static partial class UmbracoBuilderExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the culture dictionary factory.
|
||||
/// Sets the culture dictionary factory used for localization in the application.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder.</param>
|
||||
/// <param name="factory">A function creating a culture dictionary factory.</param>
|
||||
/// <param name="builder">The Umbraco builder to configure.</param>
|
||||
/// <param name="factory">A function that creates an <see cref="ICultureDictionaryFactory"/> instance.</param>
|
||||
/// <returns>The <paramref name="builder"/> instance for chaining.</returns>
|
||||
public static IUmbracoBuilder SetCultureDictionaryFactory(
|
||||
this IUmbracoBuilder builder,
|
||||
Func<IServiceProvider, ICultureDictionaryFactory> factory)
|
||||
@@ -53,10 +55,11 @@ public static partial class UmbracoBuilderExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the culture dictionary factory.
|
||||
/// Sets the <see cref="ICultureDictionaryFactory"/> implementation to be used by the Umbraco builder.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder.</param>
|
||||
/// <param name="factory">A factory.</param>
|
||||
/// <param name="builder">The <see cref="IUmbracoBuilder"/> to configure.</param>
|
||||
/// <param name="factory">The <see cref="ICultureDictionaryFactory"/> instance to use for culture dictionary operations.</param>
|
||||
/// <returns>The configured <see cref="IUmbracoBuilder"/> instance.</returns>
|
||||
public static IUmbracoBuilder SetCultureDictionaryFactory(
|
||||
this IUmbracoBuilder builder,
|
||||
ICultureDictionaryFactory factory)
|
||||
@@ -66,10 +69,11 @@ public static partial class UmbracoBuilderExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the published content model factory.
|
||||
/// Configures the <see cref="IPublishedModelFactory"/> implementation to use the specified factory type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the factory.</typeparam>
|
||||
/// <param name="builder">The builder.</param>
|
||||
/// <typeparam name="T">The type of the published content model factory to register. Must implement <see cref="IPublishedModelFactory"/>.</typeparam>
|
||||
/// <param name="builder">The <see cref="IUmbracoBuilder"/> to configure.</param>
|
||||
/// <returns>The same <see cref="IUmbracoBuilder"/> instance so that multiple calls can be chained.</returns>
|
||||
public static IUmbracoBuilder SetPublishedContentModelFactory<T>(this IUmbracoBuilder builder)
|
||||
where T : class, IPublishedModelFactory
|
||||
{
|
||||
@@ -82,6 +86,7 @@ public static partial class UmbracoBuilderExtensions
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder.</param>
|
||||
/// <param name="factory">A function creating a published content model factory.</param>
|
||||
/// <returns>The builder.</returns>
|
||||
public static IUmbracoBuilder SetPublishedContentModelFactory(
|
||||
this IUmbracoBuilder builder,
|
||||
Func<IServiceProvider, IPublishedModelFactory> factory)
|
||||
@@ -91,10 +96,11 @@ public static partial class UmbracoBuilderExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the published content model factory.
|
||||
/// Sets the published content model factory to the specified <see cref="IPublishedModelFactory"/> implementation.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder.</param>
|
||||
/// <param name="factory">A published content model factory.</param>
|
||||
/// <param name="builder">The <see cref="IUmbracoBuilder"/> to configure.</param>
|
||||
/// <param name="factory">The <see cref="IPublishedModelFactory"/> instance to use.</param>
|
||||
/// <returns>The same <see cref="IUmbracoBuilder"/> instance so that multiple calls can be chained.</returns>
|
||||
public static IUmbracoBuilder SetPublishedContentModelFactory(
|
||||
this IUmbracoBuilder builder,
|
||||
IPublishedModelFactory factory)
|
||||
@@ -104,10 +110,11 @@ public static partial class UmbracoBuilderExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the short string helper.
|
||||
/// Configures the <see cref="IShortStringHelper"/> implementation to use the specified type <typeparamref name="T"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the short string helper.</typeparam>
|
||||
/// <param name="builder">The builder.</param>
|
||||
/// <typeparam name="T">The type of the short string helper to register. Must implement <see cref="IShortStringHelper"/>.</typeparam>
|
||||
/// <param name="builder">The Umbraco builder to configure.</param>
|
||||
/// <returns>The same <paramref name="builder"/> instance so that additional calls can be chained.</returns>
|
||||
public static IUmbracoBuilder SetShortStringHelper<T>(this IUmbracoBuilder builder)
|
||||
where T : class, IShortStringHelper
|
||||
{
|
||||
@@ -116,10 +123,11 @@ public static partial class UmbracoBuilderExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the short string helper.
|
||||
/// Configures the <see cref="IShortStringHelper"/> implementation to use within the Umbraco builder by specifying a factory function.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder.</param>
|
||||
/// <param name="factory">A function creating a short string helper.</param>
|
||||
/// <param name="builder">The Umbraco builder to configure.</param>
|
||||
/// <param name="factory">A factory function that creates an <see cref="IShortStringHelper"/> instance.</param>
|
||||
/// <returns>The configured <see cref="IUmbracoBuilder"/> instance.</returns>
|
||||
public static IUmbracoBuilder SetShortStringHelper(
|
||||
this IUmbracoBuilder builder,
|
||||
Func<IServiceProvider, IShortStringHelper> factory)
|
||||
@@ -129,10 +137,11 @@ public static partial class UmbracoBuilderExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the short string helper.
|
||||
/// Sets the <see cref="IShortStringHelper"/> implementation to use for the Umbraco builder.
|
||||
/// </summary>
|
||||
/// <param name="builder">A builder.</param>
|
||||
/// <param name="helper">A short string helper.</param>
|
||||
/// <param name="builder">The <see cref="IUmbracoBuilder"/> to configure.</param>
|
||||
/// <param name="helper">The <see cref="IShortStringHelper"/> instance to register.</param>
|
||||
/// <returns>The configured <see cref="IUmbracoBuilder"/> instance.</returns>
|
||||
public static IUmbracoBuilder SetShortStringHelper(this IUmbracoBuilder builder, IShortStringHelper helper)
|
||||
{
|
||||
builder.Services.AddUnique(helper);
|
||||
@@ -144,6 +153,7 @@ public static partial class UmbracoBuilderExtensions
|
||||
/// </summary>
|
||||
/// <param name="builder">A builder.</param>
|
||||
/// <param name="filesystemFactory">Factory method to create an IFileSystem implementation used in the MediaFileManager</param>
|
||||
/// <returns>The <see cref="IUmbracoBuilder"/> instance.</returns>
|
||||
public static IUmbracoBuilder SetMediaFileSystem(
|
||||
this IUmbracoBuilder builder,
|
||||
Func<IServiceProvider, IFileSystem> filesystemFactory)
|
||||
@@ -171,6 +181,7 @@ public static partial class UmbracoBuilderExtensions
|
||||
/// <param name="configure">Method that configures the <see cref="FileSystems" />.</param>
|
||||
/// <exception cref="ArgumentNullException">Throws exception if <paramref name="configure" /> is null.</exception>
|
||||
/// <exception cref="InvalidOperationException">Throws exception if full path can't be resolved successfully.</exception>
|
||||
/// <returns>The <see cref="IUmbracoBuilder" />.</returns>
|
||||
public static IUmbracoBuilder ConfigureFileSystems(
|
||||
this IUmbracoBuilder builder,
|
||||
Action<IServiceProvider, FileSystems> configure)
|
||||
@@ -216,10 +227,11 @@ public static partial class UmbracoBuilderExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the log viewer.
|
||||
/// Configures the <see cref="ILogViewer"/> implementation to be used by the Umbraco builder.
|
||||
/// </summary>
|
||||
/// <param name="builder">A builder.</param>
|
||||
/// <param name="viewer">A log viewer.</param>
|
||||
/// <param name="builder">The <see cref="IUmbracoBuilder"/> used to configure services.</param>
|
||||
/// <param name="viewer">The <see cref="ILogViewer"/> instance to register.</param>
|
||||
/// <returns>The <see cref="IUmbracoBuilder"/> instance for chaining.</returns>
|
||||
[Obsolete("No longer used. Scheduled for removal in Umbraco 18.")]
|
||||
public static IUmbracoBuilder SetLogViewer(this IUmbracoBuilder builder, ILogViewer viewer)
|
||||
{
|
||||
|
||||
@@ -5,8 +5,17 @@ using Umbraco.Cms.Infrastructure.Telemetry.Providers;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.DependencyInjection;
|
||||
|
||||
/// <summary>
|
||||
/// Contains extension methods for registering telemetry providers with the Umbraco builder.
|
||||
/// </summary>
|
||||
public static class UmbracoBuilder_TelemetryProviders
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers all default <see cref="IDetailedTelemetryProvider"/> implementations with the Umbraco builder's service collection.
|
||||
/// This enables telemetry data collection from various sources such as content, domains, media, users, and more.
|
||||
/// </summary>
|
||||
/// <param name="builder">The <see cref="IUmbracoBuilder"/> to which telemetry providers will be added.</param>
|
||||
/// <returns>The same <see cref="IUmbracoBuilder"/> instance so that multiple calls can be chained.</returns>
|
||||
public static IUmbracoBuilder AddTelemetryProviders(this IUmbracoBuilder builder)
|
||||
{
|
||||
builder.Services.AddTransient<IDetailedTelemetryProvider, ContentTelemetryProvider>();
|
||||
|
||||
+11
@@ -4,6 +4,9 @@ using Umbraco.Cms.Core.DistributedLocking;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.DistributedLocking;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the default factory for creating distributed locking mechanisms in Umbraco.
|
||||
/// </summary>
|
||||
public class DefaultDistributedLockingMechanismFactory : IDistributedLockingMechanismFactory
|
||||
{
|
||||
private readonly IEnumerable<IDistributedLockingMechanism> _distributedLockingMechanisms;
|
||||
@@ -13,6 +16,11 @@ public class DefaultDistributedLockingMechanismFactory : IDistributedLockingMech
|
||||
private bool _initialized;
|
||||
private object _lock = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DefaultDistributedLockingMechanismFactory"/> class.
|
||||
/// </summary>
|
||||
/// <param name="globalSettings">An <see cref="IOptionsMonitor{T}"/> for accessing <see cref="GlobalSettings"/> at runtime.</param>
|
||||
/// <param name="distributedLockingMechanisms">A collection of available <see cref="IDistributedLockingMechanism"/> implementations to be used by the factory.</param>
|
||||
public DefaultDistributedLockingMechanismFactory(
|
||||
IOptionsMonitor<GlobalSettings> globalSettings,
|
||||
IEnumerable<IDistributedLockingMechanism> distributedLockingMechanisms)
|
||||
@@ -21,6 +29,9 @@ public class DefaultDistributedLockingMechanismFactory : IDistributedLockingMech
|
||||
_distributedLockingMechanisms = distributedLockingMechanisms;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current instance of the distributed locking mechanism, ensuring it is initialized.
|
||||
/// </summary>
|
||||
public IDistributedLockingMechanism DistributedLockingMechanism
|
||||
{
|
||||
get
|
||||
|
||||
@@ -1,15 +1,33 @@
|
||||
using Umbraco.Cms.Core.Semver;
|
||||
using Umbraco.Cms.Core.Semver;
|
||||
using Umbraco.Cms.Infrastructure.Migrations;
|
||||
|
||||
namespace Umbraco.Cms.Core.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Provides data for events that occur during Umbraco database migrations.
|
||||
/// </summary>
|
||||
public class MigrationEventArgs : CancellableObjectEventArgs<IList<Type>>, IEquatable<MigrationEventArgs>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Core.Events.MigrationEventArgs"/> class.
|
||||
/// </summary>
|
||||
/// <param name="migrationTypes">A list of migration types that are part of the migration process.</param>
|
||||
/// <param name="configuredVersion">The version currently configured before migration begins.</param>
|
||||
/// <param name="targetVersion">The version to which the migration will be performed.</param>
|
||||
/// <param name="productName">The name of the product undergoing migration.</param>
|
||||
/// <param name="canCancel">True if the migration process can be cancelled; otherwise, false.</param>
|
||||
public MigrationEventArgs(IList<Type> migrationTypes, SemVersion configuredVersion, SemVersion targetVersion, string productName, bool canCancel)
|
||||
: this(migrationTypes, null, configuredVersion, targetVersion, productName, canCancel)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Core.Events.MigrationEventArgs"/> class.
|
||||
/// </summary>
|
||||
/// <param name="migrationTypes">A list of migration types that are being executed.</param>
|
||||
/// <param name="configuredVersion">The version configured before the migration starts.</param>
|
||||
/// <param name="targetVersion">The version to which the migration is being applied.</param>
|
||||
/// <param name="productName">The name of the product undergoing migration.</param>
|
||||
public MigrationEventArgs(IList<Type> migrationTypes, SemVersion configuredVersion, SemVersion targetVersion, string productName)
|
||||
: this(migrationTypes, null, configuredVersion, targetVersion, productName, false)
|
||||
{
|
||||
@@ -54,6 +72,14 @@ public class MigrationEventArgs : CancellableObjectEventArgs<IList<Type>>, IEqua
|
||||
|
||||
public static bool operator !=(MigrationEventArgs left, MigrationEventArgs right) => !Equals(left, right);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the current <see cref="Umbraco.Cms.Core.Events.MigrationEventArgs"/> instance is equal to another instance of the same type.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="Umbraco.Cms.Core.Events.MigrationEventArgs"/> to compare with the current instance.</param>
|
||||
/// <returns><c>true</c> if the specified instance is equal to the current instance; otherwise, <c>false</c>.</returns>
|
||||
/// <remarks>
|
||||
/// Equality is determined by comparing the values of <c>ConfiguredSemVersion</c>, <c>MigrationContext</c>, <c>ProductName</c>, and <c>TargetSemVersion</c>.
|
||||
/// </remarks>
|
||||
public bool Equals(MigrationEventArgs? other)
|
||||
{
|
||||
if (ReferenceEquals(null, other))
|
||||
@@ -71,6 +97,11 @@ public class MigrationEventArgs : CancellableObjectEventArgs<IList<Type>>, IEqua
|
||||
string.Equals(ProductName, other.ProductName) && TargetSemVersion.Equals(other.TargetSemVersion);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified object is equal to the current <see cref="MigrationEventArgs"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with the current instance.</param>
|
||||
/// <returns><c>true</c> if the specified object is equal to the current instance; otherwise, <c>false</c>.</returns>
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj))
|
||||
@@ -91,6 +122,10 @@ public class MigrationEventArgs : CancellableObjectEventArgs<IList<Type>>, IEqua
|
||||
return Equals((MigrationEventArgs)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a hash code for this instance, based on its property values.
|
||||
/// </summary>
|
||||
/// <returns>A hash code for the current <see cref="MigrationEventArgs"/> object.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
|
||||
@@ -14,6 +14,11 @@ using Umbraco.Extensions;
|
||||
namespace Umbraco.Cms.Core.Events;
|
||||
|
||||
// TODO: lots of duplicate code in this one, refactor
|
||||
|
||||
/// <summary>
|
||||
/// Handles notifications triggered when content is moved to the recycle bin ("trash") in Umbraco,
|
||||
/// and manages the relationships between the trashed content and other entities accordingly.
|
||||
/// </summary>
|
||||
public sealed class RelateOnTrashNotificationHandler :
|
||||
INotificationHandler<ContentMovedNotification>,
|
||||
INotificationHandler<ContentMovedToRecycleBinNotification>,
|
||||
@@ -30,6 +35,16 @@ public sealed class RelateOnTrashNotificationHandler :
|
||||
private readonly IUserIdKeyResolver _userIdKeyResolver;
|
||||
private readonly ILocalizedTextService _textService;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RelateOnTrashNotificationHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="relationService">Service used to manage relations between entities.</param>
|
||||
/// <param name="entityService">Service used to manage entities within Umbraco.</param>
|
||||
/// <param name="textService">Service for retrieving localized text resources.</param>
|
||||
/// <param name="auditService">Service for logging audit events.</param>
|
||||
/// <param name="scopeProvider">Provider for managing database scopes.</param>
|
||||
/// <param name="backOfficeSecurityAccessor">Accessor for back office security context.</param>
|
||||
/// <param name="userIdKeyResolver">Resolves user ID keys for operations.</param>
|
||||
public RelateOnTrashNotificationHandler(
|
||||
IRelationService relationService,
|
||||
IEntityService entityService,
|
||||
@@ -48,6 +63,16 @@ public sealed class RelateOnTrashNotificationHandler :
|
||||
_userIdKeyResolver = userIdKeyResolver;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Core.Events.RelateOnTrashNotificationHandler"/> class.
|
||||
/// Handles the creation of relations when entities are moved to the recycle bin (trashed).
|
||||
/// </summary>
|
||||
/// <param name="relationService">Service used to manage relations between entities.</param>
|
||||
/// <param name="entityService">Service for accessing and managing entities.</param>
|
||||
/// <param name="textService">Service for retrieving localized text strings.</param>
|
||||
/// <param name="auditService">Service for logging audit events.</param>
|
||||
/// <param name="scopeProvider">Provides scope management for database operations.</param>
|
||||
/// <param name="backOfficeSecurityAccessor">Accessor for back office security context.</param>
|
||||
[Obsolete("Use the non-obsolete constructor instead. Scheduled for removal in Umbraco 19.")]
|
||||
public RelateOnTrashNotificationHandler(
|
||||
IRelationService relationService,
|
||||
@@ -67,6 +92,10 @@ public sealed class RelateOnTrashNotificationHandler :
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles a <see cref="ContentMovedNotification"/> by removing parent-child relations for content items that have been moved to the recycle bin.
|
||||
/// </summary>
|
||||
/// <param name="notification">The notification containing information about the moved content items.</param>
|
||||
public void Handle(ContentMovedNotification notification)
|
||||
{
|
||||
foreach (MoveEventInfo<IContent> item in notification.MoveInfoCollection.Where(x =>
|
||||
@@ -131,10 +160,19 @@ public sealed class RelateOnTrashNotificationHandler :
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles a notification when content is moved to the recycle bin by creating parent-child relations
|
||||
/// of type 'Relate Parent Document On Delete' to remember the original parent for potential restore.
|
||||
/// </summary>
|
||||
/// <param name="notification">The notification containing details about the content items that have been moved to the recycle bin.</param>
|
||||
[Obsolete("Use the INotificationAsyncHandler.HandleAsync implementation instead. Scheduled for removal in Umbraco 19.")]
|
||||
public void Handle(ContentMovedToRecycleBinNotification notification)
|
||||
=> HandleAsync(notification, CancellationToken.None).GetAwaiter().GetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Handles a <see cref="MediaMovedNotification"/> by removing parent-child relations for media items that have been moved out of the recycle bin.
|
||||
/// </summary>
|
||||
/// <param name="notification">The notification containing information about the moved media items.</param>
|
||||
public void Handle(MediaMovedNotification notification)
|
||||
{
|
||||
foreach (MoveEventInfo<IMedia> item in notification.MoveInfoCollection.Where(x =>
|
||||
@@ -196,6 +234,10 @@ public sealed class RelateOnTrashNotificationHandler :
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles a <see cref="MediaMovedToRecycleBinNotification"/> by removing relations when media is moved to the recycle bin.
|
||||
/// </summary>
|
||||
/// <param name="notification">The notification containing information about the media items that were moved to the recycle bin.</param>
|
||||
[Obsolete("Use the INotificationAsyncHandler.HandleAsync implementation instead. Scheduled for removal in Umbraco 19.")]
|
||||
public void Handle(MediaMovedToRecycleBinNotification notification)
|
||||
=> HandleAsync(notification, CancellationToken.None).GetAwaiter().GetResult();
|
||||
|
||||
@@ -31,6 +31,13 @@ public class ContentIndexPopulator : IndexPopulator<IUmbracoContentIndex>
|
||||
/// </summary>
|
||||
private IQuery<IContent>? _publishedQuery;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ContentIndexPopulator"/> class, which is responsible for populating the content index in Examine.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger used for logging diagnostic and error information.</param>
|
||||
/// <param name="contentService">The service used to access and manage Umbraco content items.</param>
|
||||
/// <param name="umbracoDatabaseFactory">The factory for creating Umbraco database connections.</param>
|
||||
/// <param name="contentValueSetBuilder">The builder used to create value sets for content indexing.</param>
|
||||
[Obsolete("Please use the non-obsolete constructor. Scheduled for removal in Umbraco 19.")]
|
||||
public ContentIndexPopulator(
|
||||
ILogger<ContentIndexPopulator> logger,
|
||||
@@ -42,8 +49,13 @@ public class ContentIndexPopulator : IndexPopulator<IUmbracoContentIndex>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor to lookup all content data
|
||||
/// Initializes a new instance of the <see cref="ContentIndexPopulator"/> class, used to populate the content index with all content data.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger instance used for diagnostic and error logging.</param>
|
||||
/// <param name="contentService">The service used to access and manage content items.</param>
|
||||
/// <param name="umbracoDatabaseFactory">The factory for creating Umbraco database connections.</param>
|
||||
/// <param name="contentValueSetBuilder">Builds value sets for content items to be indexed.</param>
|
||||
/// <param name="indexingSettings">The monitor providing indexing configuration settings.</param>
|
||||
public ContentIndexPopulator(
|
||||
ILogger<ContentIndexPopulator> logger,
|
||||
IContentService contentService,
|
||||
@@ -54,6 +66,15 @@ public class ContentIndexPopulator : IndexPopulator<IUmbracoContentIndex>
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ContentIndexPopulator"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger used for diagnostic and operational messages.</param>
|
||||
/// <param name="publishedValuesOnly">If set to <c>true</c>, only published content values are indexed.</param>
|
||||
/// <param name="parentId">An optional parent content ID to restrict indexing to its descendants, or <c>null</c> for all content.</param>
|
||||
/// <param name="contentService">Service for accessing and managing content items.</param>
|
||||
/// <param name="umbracoDatabaseFactory">Factory for obtaining Umbraco database connections.</param>
|
||||
/// <param name="contentValueSetBuilder">Builds value sets for content items to be indexed.</param>
|
||||
[Obsolete("Please use the non-obsolete constructor. Scheduled for removal in Umbraco 19.")]
|
||||
public ContentIndexPopulator(
|
||||
ILogger<ContentIndexPopulator> logger,
|
||||
@@ -67,8 +88,15 @@ public class ContentIndexPopulator : IndexPopulator<IUmbracoContentIndex>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Optional constructor allowing specifying custom query parameters
|
||||
/// Initializes a new instance of the <see cref="ContentIndexPopulator"/> class with custom query parameters.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger used for diagnostic and error messages.</param>
|
||||
/// <param name="publishedValuesOnly">If true, only published content values are indexed.</param>
|
||||
/// <param name="parentId">An optional parent content ID to restrict indexing to a subtree.</param>
|
||||
/// <param name="contentService">The service used to access content items.</param>
|
||||
/// <param name="umbracoDatabaseFactory">The factory for obtaining Umbraco database connections.</param>
|
||||
/// <param name="contentValueSetBuilder">Builds value sets for content items to be indexed.</param>
|
||||
/// <param name="indexingSettings">Monitors configuration settings for indexing.</param>
|
||||
public ContentIndexPopulator(
|
||||
ILogger<ContentIndexPopulator> logger,
|
||||
bool publishedValuesOnly,
|
||||
@@ -95,6 +123,11 @@ public class ContentIndexPopulator : IndexPopulator<IUmbracoContentIndex>
|
||||
private IQuery<IContent> PublishedQuery => _publishedQuery ??=
|
||||
_umbracoDatabaseFactory.SqlContext.Query<IContent>().Where(x => x.Published);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified content index is registered for population.
|
||||
/// </summary>
|
||||
/// <param name="index">The content index to check.</param>
|
||||
/// <returns><c>true</c> if the content index is registered; otherwise, <c>false</c>.</returns>
|
||||
public override bool IsRegistered(IUmbracoContentIndex index) =>
|
||||
|
||||
// check if it should populate based on published values
|
||||
|
||||
@@ -30,6 +30,20 @@ public class ContentValueSetBuilder : BaseValueSetBuilder<IContent>, IContentVal
|
||||
private readonly IDocumentUrlService _documentUrlService;
|
||||
private readonly ILanguageService _languageService;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Infrastructure.Examine.ContentValueSetBuilder"/> class.
|
||||
/// </summary>
|
||||
/// <param name="propertyEditors">A collection of property editors used for value extraction.</param>
|
||||
/// <param name="urlSegmentProviders">A collection of URL segment providers for generating URL segments.</param>
|
||||
/// <param name="userService">The service used to manage users.</param>
|
||||
/// <param name="shortStringHelper">The helper used for generating and manipulating short strings.</param>
|
||||
/// <param name="scopeProvider">The provider for managing database scopes.</param>
|
||||
/// <param name="publishedValuesOnly">If set to <c>true</c>, only published values will be used.</param>
|
||||
/// <param name="localizationService">The service used for localization and translations.</param>
|
||||
/// <param name="contentTypeService">The service used to manage content types.</param>
|
||||
/// <param name="logger">The logger used for logging information and errors.</param>
|
||||
/// <param name="documentUrlService">The service used to generate document URLs.</param>
|
||||
/// <param name="languageService">The service used to manage languages.</param>
|
||||
public ContentValueSetBuilder(
|
||||
PropertyEditorCollection propertyEditors,
|
||||
UrlSegmentProviderCollection urlSegmentProviders,
|
||||
|
||||
@@ -23,6 +23,18 @@ public class ContentValueSetValidator : ValueSetValidator, IContentValueSetValid
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ContentValueSetValidator"/> class.
|
||||
/// </summary>
|
||||
/// <param name="publishedValuesOnly">If <c>true</c>, only published values are validated.</param>
|
||||
/// <param name="supportProtectedContent">If <c>true</c>, enables validation of protected content.</param>
|
||||
/// <param name="publicAccessService">The service used to check public access permissions. May be <c>null</c>.</param>
|
||||
/// <param name="scopeProvider">The provider for managing database scopes. May be <c>null</c>.</param>
|
||||
/// <param name="parentId">Optional parent content ID to filter by. Defaults to <c>null</c>.</param>
|
||||
/// <param name="includeItemTypes">Optional collection of item types to include in validation. Defaults to <c>null</c> (all types included).</param>
|
||||
/// <param name="excludeItemTypes">Optional collection of item types to exclude from validation. Defaults to <c>null</c>.</param>
|
||||
/// <param name="includeFields">Optional collection of field names to include in validation. Defaults to <c>null</c> (all fields included).</param>
|
||||
/// <param name="excludeFields">Optional collection of field names to exclude from validation. Defaults to <c>null</c>.</param>
|
||||
public ContentValueSetValidator(
|
||||
bool publishedValuesOnly,
|
||||
bool supportProtectedContent,
|
||||
@@ -44,10 +56,29 @@ public class ContentValueSetValidator : ValueSetValidator, IContentValueSetValid
|
||||
|
||||
protected override IEnumerable<string> ValidIndexCategories => ValidCategories;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the validator includes only published content values.
|
||||
/// </summary>
|
||||
public bool PublishedValuesOnly { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this validator supports protected content.
|
||||
/// </summary>
|
||||
public bool SupportProtectedContent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the identifier of the parent content item, if available.
|
||||
/// </summary>
|
||||
public int? ParentId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified <paramref name="path"/> represents a descendant of the configured parent, based on the provided <paramref name="category"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">The comma-delimited string representing the content path to validate.</param>
|
||||
/// <param name="category">The category of the content, used for validation context.</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if the <paramref name="path"/> contains the parent ID and is considered valid; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
public bool ValidatePath(string path, string category)
|
||||
{
|
||||
//check if this document is a descendent of the parent
|
||||
@@ -64,6 +95,14 @@ public class ContentValueSetValidator : ValueSetValidator, IContentValueSetValid
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified path is outside of the recycle bin for the given category.
|
||||
/// </summary>
|
||||
/// <param name="path">The comma-delimited path string to validate.</param>
|
||||
/// <param name="category">The category (e.g., content or media) used to determine the appropriate recycle bin.</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if <paramref name="path"/> does not include the recycle bin for the specified <paramref name="category"/> (when <c>PublishedValuesOnly</c> is <c>true</c>); otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
public bool ValidateRecycleBin(string path, string category)
|
||||
{
|
||||
var recycleBinId = category == IndexTypes.Content
|
||||
@@ -82,6 +121,14 @@ public class ContentValueSetValidator : ValueSetValidator, IContentValueSetValid
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the content at the specified path is allowed to be indexed based on its protection status and the given category.
|
||||
/// </summary>
|
||||
/// <param name="path">The content path to check for protection.</param>
|
||||
/// <param name="category">The category of the content, typically the index type (e.g., <c>IndexTypes.Content</c>).</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if the content is not protected, protection is not supported, or the category does not require protection checks; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
public bool ValidateProtectedContent(string path, string category)
|
||||
{
|
||||
if (category == IndexTypes.Content && !SupportProtectedContent)
|
||||
@@ -105,6 +152,29 @@ public class ContentValueSetValidator : ValueSetValidator, IContentValueSetValid
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the specified <see cref="Umbraco.Cms.Core.Models.ValueSet"/> to determine if it meets the requirements for indexing in Examine.
|
||||
/// <para>
|
||||
/// Validation includes checks for published status (including culture variants), the presence and validity of the content path, and whether the content is in the recycle bin or protected.
|
||||
/// If the value set fails any of these checks, it is either marked as failed (not indexable) or filtered (excluded from the index), depending on the nature of the issue.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="valueSet">The <see cref="Umbraco.Cms.Core.Models.ValueSet"/> to validate.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="Umbraco.Cms.Infrastructure.Examine.ValueSetValidationResult"/> indicating the outcome of the validation:
|
||||
/// <list type="bullet">
|
||||
/// <item>
|
||||
/// <description><c>Valid</c>: The value set passed all checks and is suitable for indexing.</description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <description><c>Filtered</c>: The value set should be excluded from the index due to path, recycle bin, or protected content rules.</description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <description><c>Failed</c>: The value set is invalid (for example, missing required fields) and cannot be indexed.</description>
|
||||
/// </item>
|
||||
/// </list>
|
||||
/// The result may also contain a filtered version of the original value set with unpublished culture variants removed.
|
||||
/// </returns>
|
||||
public override ValueSetValidationResult Validate(ValueSet valueSet)
|
||||
{
|
||||
// Notes on status on the result:
|
||||
|
||||
+35
@@ -16,6 +16,15 @@ internal sealed class DeliveryApiContentIndexHandleContentChanges : DeliveryApiC
|
||||
private readonly IDeliveryApiContentIndexHelper _deliveryApiContentIndexHelper;
|
||||
private readonly IBackgroundTaskQueue _backgroundTaskQueue;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeliveryApiContentIndexHandleContentChanges"/> class.
|
||||
/// </summary>
|
||||
/// <param name="changes">A list of key-value pairs representing content item IDs and their associated <see cref="TreeChangeTypes"/> to be handled.</param>
|
||||
/// <param name="deliveryApiIndexingHandler">The handler responsible for managing Delivery API content indexing operations.</param>
|
||||
/// <param name="contentService">The service used to access and manage content items.</param>
|
||||
/// <param name="deliveryApiContentIndexValueSetBuilder">Builds value sets for indexing Delivery API content.</param>
|
||||
/// <param name="deliveryApiContentIndexHelper">Provides helper methods for Delivery API content indexing.</param>
|
||||
/// <param name="backgroundTaskQueue">A queue for scheduling background tasks related to content indexing.</param>
|
||||
public DeliveryApiContentIndexHandleContentChanges(
|
||||
IList<KeyValuePair<int, TreeChangeTypes>> changes,
|
||||
DeliveryApiIndexingHandler deliveryApiIndexingHandler,
|
||||
@@ -32,6 +41,12 @@ internal sealed class DeliveryApiContentIndexHandleContentChanges : DeliveryApiC
|
||||
_deliveryApiContentIndexHelper = deliveryApiContentIndexHelper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes pending content changes for the delivery API content index.
|
||||
/// This method queues a background work item that removes or reindexes content items as needed,
|
||||
/// ensuring the index reflects the latest content state. Content removals and reindexing are handled
|
||||
/// based on the type of change detected for each content item.
|
||||
/// </summary>
|
||||
public void Execute() => _backgroundTaskQueue.QueueBackgroundWorkItem(_ =>
|
||||
{
|
||||
IIndex index = _deliveryApiIndexingHandler.GetIndex()
|
||||
@@ -153,10 +168,21 @@ internal sealed class DeliveryApiContentIndexHandleContentChanges : DeliveryApiC
|
||||
|
||||
private sealed class CulturePublishStatus : IEquatable<CulturePublishStatus>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the culture identifier for the publish status.
|
||||
/// </summary>
|
||||
public required string Culture { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value indicating the published status for the specific culture.
|
||||
/// </summary>
|
||||
public required string Published { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified <see cref="CulturePublishStatus"/> is equal to the current instance.
|
||||
/// </summary>
|
||||
/// <param name="other">The other <see cref="CulturePublishStatus"/> to compare with this instance.</param>
|
||||
/// <returns><c>true</c> if the specified <see cref="CulturePublishStatus"/> is equal to the current instance; otherwise, <c>false</c>.</returns>
|
||||
public bool Equals(CulturePublishStatus? other)
|
||||
{
|
||||
if (ReferenceEquals(null, other))
|
||||
@@ -172,6 +198,11 @@ internal sealed class DeliveryApiContentIndexHandleContentChanges : DeliveryApiC
|
||||
return Culture == other.Culture && Published == other.Published;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified object is equal to the current <see cref="CulturePublishStatus"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with the current instance.</param>
|
||||
/// <returns><c>true</c> if the specified object is equal to the current instance; otherwise, <c>false</c>.</returns>
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj))
|
||||
@@ -192,6 +223,10 @@ internal sealed class DeliveryApiContentIndexHandleContentChanges : DeliveryApiC
|
||||
return Equals((CulturePublishStatus)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a hash code for this instance, computed from the <c>Culture</c> and <c>Published</c> properties.
|
||||
/// </summary>
|
||||
/// <returns>A hash code for the current <see cref="CulturePublishStatus"/> object.</returns>
|
||||
public override int GetHashCode() => HashCode.Combine(Culture, Published);
|
||||
}
|
||||
|
||||
|
||||
+14
@@ -20,6 +20,15 @@ internal sealed class DeliveryApiContentIndexHandleContentTypeChanges : Delivery
|
||||
private readonly IBackgroundTaskQueue _backgroundTaskQueue;
|
||||
private readonly IDeliveryApiCompositeIdHandler _deliveryApiCompositeIdHandler;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeliveryApiContentIndexHandleContentTypeChanges"/> class, responsible for handling content type changes and updating the Delivery API content index accordingly.
|
||||
/// </summary>
|
||||
/// <param name="changes">A list of key-value pairs representing content type IDs and their associated change types to be processed.</param>
|
||||
/// <param name="deliveryApiIndexingHandler">The handler responsible for managing Delivery API indexing operations.</param>
|
||||
/// <param name="deliveryApiContentIndexValueSetBuilder">The builder used to create value sets for indexing Delivery API content.</param>
|
||||
/// <param name="contentService">The service used to access and manage content items.</param>
|
||||
/// <param name="backgroundTaskQueue">The queue for scheduling background tasks related to indexing.</param>
|
||||
/// <param name="deliveryApiCompositeIdHandler">The handler for managing composite IDs within the Delivery API.</param>
|
||||
public DeliveryApiContentIndexHandleContentTypeChanges(
|
||||
IList<KeyValuePair<int, ContentTypeChangeTypes>> changes,
|
||||
DeliveryApiIndexingHandler deliveryApiIndexingHandler,
|
||||
@@ -36,6 +45,11 @@ internal sealed class DeliveryApiContentIndexHandleContentTypeChanges : Delivery
|
||||
_deliveryApiCompositeIdHandler = deliveryApiCompositeIdHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initiates asynchronous processing of content type changes for the Delivery API content index.
|
||||
/// This method queues a background work item that examines tracked content type changes, determines which content types require updates,
|
||||
/// and updates the index accordingly. Content type deletions are handled separately by content cache refresh notifications.
|
||||
/// </summary>
|
||||
public void Execute() => _backgroundTaskQueue.QueueBackgroundWorkItem(_ =>
|
||||
{
|
||||
var updatedContentTypeIds = new List<int>();
|
||||
|
||||
+23
-4
@@ -18,6 +18,17 @@ internal sealed class DeliveryApiContentIndexHandlePublicAccessChanges : Deliver
|
||||
private readonly IContentService _contentService;
|
||||
private readonly IDeliveryApiContentIndexValueSetBuilder _deliveryApiContentIndexValueSetBuilder;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeliveryApiContentIndexHandlePublicAccessChanges"/> class,
|
||||
/// which handles updates to the Delivery API content index in response to changes in public access settings.
|
||||
/// </summary>
|
||||
/// <param name="publicAccessService">Service for managing and querying public access rules for content.</param>
|
||||
/// <param name="deliveryApiIndexingHandler">Handler responsible for managing Delivery API content indexing operations.</param>
|
||||
/// <param name="contentService">Service for accessing and managing Umbraco content items.</param>
|
||||
/// <param name="deliveryApiContentIndexValueSetBuilder">Builder for creating value sets used in Delivery API content indexing.</param>
|
||||
/// <param name="deliveryApiContentIndexHelper">Helper providing utility methods for Delivery API content indexing.</param>
|
||||
/// <param name="deliveryApiSettings">Configuration settings for the Delivery API.</param>
|
||||
/// <param name="backgroundTaskQueue">Queue for scheduling background tasks related to indexing operations.</param>
|
||||
public DeliveryApiContentIndexHandlePublicAccessChanges(
|
||||
IPublicAccessService publicAccessService,
|
||||
DeliveryApiIndexingHandler deliveryApiIndexingHandler,
|
||||
@@ -36,10 +47,18 @@ internal sealed class DeliveryApiContentIndexHandlePublicAccessChanges : Deliver
|
||||
_backgroundTaskQueue = backgroundTaskQueue;
|
||||
}
|
||||
|
||||
// NOTE: at the time of implementing this, the distributed notifications for public access changes only ever
|
||||
// sends out "refresh all" notifications, which means we can't be clever about minimizing the work
|
||||
// effort to handle public access changes. instead we have to grab all protected content definitions
|
||||
// and handle every last one with every notification.
|
||||
/// <summary>
|
||||
/// Handles changes to public access for content in the delivery API index.
|
||||
/// Queues a background task to update or remove protected content in the index
|
||||
/// according to the current member authorization settings, ensuring the index reflects
|
||||
/// the latest access rules.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// NOTE: at the time of implementing this, the distributed notifications for public access changes only ever
|
||||
/// sends out "refresh all" notifications, which means we can't be clever about minimizing the work
|
||||
/// effort to handle public access changes. instead we have to grab all protected content definitions
|
||||
/// and handle every last one with every notification.
|
||||
/// </remarks>
|
||||
public void Execute() => _backgroundTaskQueue.QueueBackgroundWorkItem(_ =>
|
||||
{
|
||||
IIndex index = _deliveryApiIndexingHandler.GetIndex() ??
|
||||
|
||||
@@ -11,6 +11,13 @@ internal sealed class DeferredActions
|
||||
|
||||
private readonly List<IDeferredAction> _actions = new();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the <see cref="DeferredActions"/> instance enlisted in the current scope context associated with the specified <paramref name="scopeProvider"/>.
|
||||
/// </summary>
|
||||
/// <param name="scopeProvider">The scope provider from which to obtain the current scope context.</param>
|
||||
/// <returns>
|
||||
/// The <see cref="DeferredActions"/> instance enlisted in the current scope, or <c>null</c> if no scope context is available.
|
||||
/// </returns>
|
||||
public static DeferredActions? Get(ICoreScopeProvider scopeProvider)
|
||||
{
|
||||
IScopeContext? scopeContext = scopeProvider.Context;
|
||||
@@ -28,6 +35,10 @@ internal sealed class DeferredActions
|
||||
EnlistPriority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified deferred action to the collection of actions to be executed later.
|
||||
/// </summary>
|
||||
/// <param name="action">The <see cref="IDeferredAction"/> to add to the collection.</param>
|
||||
public void Add(IDeferredAction action) => _actions.Add(action);
|
||||
|
||||
private void Execute()
|
||||
|
||||
+13
-1
@@ -1,4 +1,4 @@
|
||||
using Examine;
|
||||
using Examine;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Umbraco.Cms.Core.DeliveryApi;
|
||||
using Umbraco.Extensions;
|
||||
@@ -10,6 +10,12 @@ internal sealed class DeliveryApiContentIndexFieldDefinitionBuilder : IDeliveryA
|
||||
private readonly ContentIndexHandlerCollection _indexHandlers;
|
||||
private readonly ILogger<DeliveryApiContentIndexFieldDefinitionBuilder> _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Infrastructure.Examine.DeliveryApiContentIndexFieldDefinitionBuilder"/> class,
|
||||
/// which is responsible for building field definitions for the Delivery API content index.
|
||||
/// </summary>
|
||||
/// <param name="indexHandlers">A collection of handlers used to define how content fields are indexed for the Delivery API.</param>
|
||||
/// <param name="logger">The logger used for logging diagnostic and operational information.</param>
|
||||
public DeliveryApiContentIndexFieldDefinitionBuilder(
|
||||
ContentIndexHandlerCollection indexHandlers,
|
||||
ILogger<DeliveryApiContentIndexFieldDefinitionBuilder> logger)
|
||||
@@ -18,6 +24,12 @@ internal sealed class DeliveryApiContentIndexFieldDefinitionBuilder : IDeliveryA
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds a collection of field definitions used for the delivery API content index.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="Umbraco.Cms.Infrastructure.Examine.FieldDefinitionCollection"/> containing the generated field definitions.
|
||||
/// </returns>
|
||||
public FieldDefinitionCollection Build()
|
||||
{
|
||||
var fieldDefinitions = new List<FieldDefinition>();
|
||||
|
||||
@@ -18,6 +18,12 @@ internal sealed class DeliveryApiContentIndexHelper : IDeliveryApiContentIndexHe
|
||||
|
||||
private IndexingSettings _indexingSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeliveryApiContentIndexHelper"/> class.
|
||||
/// </summary>
|
||||
/// <param name="contentService">Service used to manage and retrieve Umbraco content items.</param>
|
||||
/// <param name="umbracoDatabaseFactory">Factory for creating Umbraco database connections.</param>
|
||||
/// <param name="deliveryApiSettings">Monitors configuration settings for the Delivery API.</param>
|
||||
[Obsolete("Please use the non-obsolete constructor. Scheduled for removal in Umbraco 19.")]
|
||||
public DeliveryApiContentIndexHelper(
|
||||
IContentService contentService,
|
||||
@@ -27,6 +33,13 @@ internal sealed class DeliveryApiContentIndexHelper : IDeliveryApiContentIndexHe
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeliveryApiContentIndexHelper"/> class.
|
||||
/// </summary>
|
||||
/// <param name="contentService">An <see cref="IContentService"/> used to access and manage content data.</param>
|
||||
/// <param name="umbracoDatabaseFactory">An <see cref="IUmbracoDatabaseFactory"/> for creating database connections.</param>
|
||||
/// <param name="deliveryApiSettings">An <see cref="IOptionsMonitor{DeliveryApiSettings}"/> providing access to Delivery API configuration settings.</param>
|
||||
/// <param name="indexingSettings">An <see cref="IOptionsMonitor{IndexingSettings}"/> providing access to indexing configuration settings.</param>
|
||||
public DeliveryApiContentIndexHelper(
|
||||
IContentService contentService,
|
||||
IUmbracoDatabaseFactory umbracoDatabaseFactory,
|
||||
@@ -41,6 +54,11 @@ internal sealed class DeliveryApiContentIndexHelper : IDeliveryApiContentIndexHe
|
||||
indexingSettings.OnChange(settings => _indexingSettings = settings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enumerates applicable descendant content items for content indexing starting from the specified root content ID.
|
||||
/// </summary>
|
||||
/// <param name="rootContentId">The ID of the root content item to start enumeration from.</param>
|
||||
/// <param name="actionToPerform">The action to perform on each batch of descendant content items.</param>
|
||||
public void EnumerateApplicableDescendantsForContentIndex(int rootContentId, Action<IContent[]> actionToPerform)
|
||||
=> EnumerateApplicableDescendantsForContentIndex(rootContentId, actionToPerform, _indexingSettings.BatchSize);
|
||||
|
||||
|
||||
@@ -13,6 +13,13 @@ internal sealed class DeliveryApiContentIndexPopulator : IndexPopulator
|
||||
private readonly ILogger<DeliveryApiContentIndexPopulator> _logger;
|
||||
private DeliveryApiSettings _deliveryApiSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeliveryApiContentIndexPopulator"/> class.
|
||||
/// </summary>
|
||||
/// <param name="deliveryContentIndexValueSetBuilder">The builder used to create value sets for the delivery API content index.</param>
|
||||
/// <param name="deliveryApiContentIndexHelper">A helper providing methods for content indexing in the delivery API.</param>
|
||||
/// <param name="logger">The logger used for logging events related to the content index populator.</param>
|
||||
/// <param name="deliveryApiSettings">The monitor providing access to the current delivery API settings.</param>
|
||||
public DeliveryApiContentIndexPopulator(
|
||||
IDeliveryApiContentIndexValueSetBuilder deliveryContentIndexValueSetBuilder,
|
||||
IDeliveryApiContentIndexHelper deliveryApiContentIndexHelper,
|
||||
|
||||
@@ -25,6 +25,18 @@ internal sealed class DeliveryApiContentIndexValueSetBuilder : IDeliveryApiConte
|
||||
private readonly ICoreScopeProvider _coreScopeProvider;
|
||||
private DeliveryApiSettings _deliveryApiSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Infrastructure.Examine.DeliveryApiContentIndexValueSetBuilder"/> class.
|
||||
/// </summary>
|
||||
/// <param name="contentIndexHandlerCollection">A collection of handlers for content indexing operations.</param>
|
||||
/// <param name="contentService">Service for managing content items.</param>
|
||||
/// <param name="publicAccessService">Service for handling public access restrictions.</param>
|
||||
/// <param name="logger">Logger for diagnostic and error messages.</param>
|
||||
/// <param name="deliveryApiContentIndexFieldDefinitionBuilder">Builder for defining content index fields for the Delivery API.</param>
|
||||
/// <param name="deliveryApiSettings">Monitor for Delivery API configuration settings.</param>
|
||||
/// <param name="memberService">Service for managing members.</param>
|
||||
/// <param name="deliveryApiCompositeIdHandler">Handler for composite IDs in the Delivery API.</param>
|
||||
/// <param name="coreScopeProvider">Provider for managing core data scopes.</param>
|
||||
public DeliveryApiContentIndexValueSetBuilder(
|
||||
ContentIndexHandlerCollection contentIndexHandlerCollection,
|
||||
IContentService contentService,
|
||||
|
||||
@@ -32,6 +32,20 @@ internal sealed class DeliveryApiIndexingHandler : IDeliveryApiIndexingHandler
|
||||
private readonly IDeliveryApiCompositeIdHandler _deliveryApiCompositeIdHandler;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Infrastructure.Examine.DeliveryApiIndexingHandler"/> class, responsible for handling Examine indexing for the Delivery API.
|
||||
/// </summary>
|
||||
/// <param name="mainDomHandler">Handles main domain (MainDom) events for Examine indexing coordination.</param>
|
||||
/// <param name="examineManager">Manages Examine indexes and searchers.</param>
|
||||
/// <param name="scopeProvider">Provides database scope management for transactional operations.</param>
|
||||
/// <param name="logger">The logger used for logging indexing operations and errors.</param>
|
||||
/// <param name="deliveryApiSettings">Monitors configuration settings for the Delivery API.</param>
|
||||
/// <param name="contentService">Service for accessing and managing Umbraco content items.</param>
|
||||
/// <param name="publicAccessService">Service for managing public access permissions on content.</param>
|
||||
/// <param name="deliveryApiContentIndexValueSetBuilder">Builds value sets for content items to be indexed for the Delivery API.</param>
|
||||
/// <param name="deliveryApiContentIndexHelper">Provides helper methods for content indexing specific to the Delivery API.</param>
|
||||
/// <param name="backgroundTaskQueue">Queue for scheduling background indexing tasks.</param>
|
||||
/// <param name="deliveryApiCompositeIdHandler">Handles composite IDs for Delivery API content indexing.</param>
|
||||
public DeliveryApiIndexingHandler(
|
||||
ExamineIndexingMainDomHandler mainDomHandler,
|
||||
IExamineManager examineManager,
|
||||
|
||||
@@ -2,21 +2,40 @@ using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the data model used for an Examine index in Umbraco.
|
||||
/// </summary>
|
||||
[DataContract(Name = "indexer", Namespace = "")]
|
||||
public class ExamineIndexModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the index.
|
||||
/// </summary>
|
||||
[DataMember(Name = "name")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The health status of the examine index.
|
||||
/// </summary>
|
||||
[DataMember(Name = "healthStatus")]
|
||||
public string? HealthStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the index is considered healthy, meaning its <c>HealthStatus</c> property equals "Healthy".
|
||||
/// </summary>
|
||||
[DataMember(Name = "isHealthy")]
|
||||
public bool IsHealthy => HealthStatus == "Healthy";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a collection of provider-specific properties for the examine index.
|
||||
/// The dictionary contains key-value pairs representing additional metadata or configuration for the index provider.
|
||||
/// </summary>
|
||||
[DataMember(Name = "providerProperties")]
|
||||
public IReadOnlyDictionary<string, object?>? ProviderProperties { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this index is allowed to be rebuilt.
|
||||
/// </summary>
|
||||
[DataMember(Name = "canRebuild")]
|
||||
public bool CanRebuild { get; set; }
|
||||
}
|
||||
|
||||
@@ -25,8 +25,14 @@ internal class ExamineIndexRebuilder : IIndexRebuilder
|
||||
private readonly IRuntimeState _runtimeState;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ExamineIndexRebuilder" /> class.
|
||||
/// Initializes a new instance of the <see cref="ExamineIndexRebuilder" /> class, responsible for rebuilding Examine indexes in Umbraco.
|
||||
/// </summary>
|
||||
/// <param name="mainDom">The <see cref="IMainDom"/> instance used to ensure single execution in a distributed environment.</param>
|
||||
/// <param name="runtimeState">The <see cref="IRuntimeState"/> providing information about the current runtime state of Umbraco.</param>
|
||||
/// <param name="logger">The <see cref="ILogger{ExamineIndexRebuilder}"/> used for logging operations and errors.</param>
|
||||
/// <param name="examineManager">The <see cref="IExamineManager"/> responsible for managing Examine indexes.</param>
|
||||
/// <param name="populators">A collection of <see cref="IIndexPopulator"/> instances used to populate the indexes.</param>
|
||||
/// <param name="longRunningOperationService">The <see cref="ILongRunningOperationService"/> used to manage and track long-running operations.</param>
|
||||
public ExamineIndexRebuilder(
|
||||
IMainDom mainDom,
|
||||
IRuntimeState runtimeState,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Examine;
|
||||
using Examine;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Umbraco.Cms.Core.Logging;
|
||||
using Umbraco.Cms.Core.Runtime;
|
||||
@@ -13,6 +13,13 @@ internal sealed class ExamineIndexingMainDomHandler
|
||||
private readonly ILogger<ExamineIndexingMainDomHandler> _logger;
|
||||
private readonly Lazy<bool> _isMainDom;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Infrastructure.Examine.ExamineIndexingMainDomHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="mainDom">The <see cref="IMainDom"/> instance representing the main domain lock.</param>
|
||||
/// <param name="profilingLogger">The <see cref="IProfilingLogger"/> used for profiling and logging operations.</param>
|
||||
/// <param name="examineManager">The <see cref="IExamineManager"/> responsible for managing Examine indexes.</param>
|
||||
/// <param name="logger">The <see cref="ILogger{ExamineIndexingMainDomHandler}"/> instance for logging.</param>
|
||||
public ExamineIndexingMainDomHandler(IMainDom mainDom, IProfilingLogger profilingLogger, IExamineManager examineManager, ILogger<ExamineIndexingMainDomHandler> logger)
|
||||
{
|
||||
_mainDom = mainDom;
|
||||
@@ -22,6 +29,10 @@ internal sealed class ExamineIndexingMainDomHandler
|
||||
_isMainDom = new Lazy<bool>(DetectMainDom);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether this instance currently holds the MainDom (main domain lock) in the application.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if this instance is the MainDom; otherwise, <c>false</c>.</returns>
|
||||
public bool IsMainDom() => _isMainDom.Value;
|
||||
|
||||
private bool DetectMainDom()
|
||||
|
||||
@@ -2,9 +2,15 @@ using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the model used to configure and interact with an Examine searcher within the Umbraco CMS infrastructure.
|
||||
/// </summary>
|
||||
[DataContract(Name = "searcher", Namespace = "")]
|
||||
public class ExamineSearcherModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the searcher.
|
||||
/// </summary>
|
||||
[DataMember(Name = "name")]
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
|
||||
@@ -28,6 +28,19 @@ internal sealed class ExamineUmbracoIndexingHandler : IUmbracoIndexingHandler
|
||||
private readonly ExamineIndexingMainDomHandler _mainDomHandler;
|
||||
private readonly IPublicAccessService _publicAccessService;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Infrastructure.Examine.ExamineUmbracoIndexingHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger used for logging diagnostic and operational information.</param>
|
||||
/// <param name="scopeProvider">Provides access to the core scope for database operations.</param>
|
||||
/// <param name="examineManager">Manages Examine indexes and searchers.</param>
|
||||
/// <param name="backgroundTaskQueue">Handles the queuing and execution of background tasks.</param>
|
||||
/// <param name="contentValueSetBuilder">Builds value sets for content items to be indexed.</param>
|
||||
/// <param name="publishedContentValueSetBuilder">Builds value sets for published content items to be indexed.</param>
|
||||
/// <param name="mediaValueSetBuilder">Builds value sets for media items to be indexed.</param>
|
||||
/// <param name="memberValueSetBuilder">Builds value sets for member items to be indexed.</param>
|
||||
/// <param name="mainDomHandler">Handles main domain (MainDom) events for Examine indexing.</param>
|
||||
/// <param name="publicAccessService">Provides services for managing public access to content.</param>
|
||||
public ExamineUmbracoIndexingHandler(
|
||||
ILogger<ExamineUmbracoIndexingHandler> logger,
|
||||
ICoreScopeProvider scopeProvider,
|
||||
@@ -218,6 +231,13 @@ internal sealed class ExamineUmbracoIndexingHandler : IUmbracoIndexingHandler
|
||||
private readonly ExamineUmbracoIndexingHandler _examineUmbracoIndexingHandler;
|
||||
private readonly bool _isPublished;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeferredReIndexForContent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="backgroundTaskQueue">The queue used to schedule background reindexing tasks.</param>
|
||||
/// <param name="examineUmbracoIndexingHandler">The handler responsible for managing Examine Umbraco indexing operations.</param>
|
||||
/// <param name="content">The content item to be re-indexed.</param>
|
||||
/// <param name="isPublished">True if the content is published; otherwise, false.</param>
|
||||
public DeferredReIndexForContent(
|
||||
IBackgroundTaskQueue backgroundTaskQueue,
|
||||
ExamineUmbracoIndexingHandler examineUmbracoIndexingHandler,
|
||||
@@ -230,9 +250,20 @@ internal sealed class ExamineUmbracoIndexingHandler : IUmbracoIndexingHandler
|
||||
_isPublished = isPublished;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the deferred re-indexing operation for the specified content item.
|
||||
/// This method processes the queued re-indexing task, updating the search index as needed.
|
||||
/// </summary>
|
||||
public void Execute() =>
|
||||
Execute(_backgroundTaskQueue, _examineUmbracoIndexingHandler, _content, _isPublished);
|
||||
|
||||
/// <summary>
|
||||
/// Executes a deferred re-indexing operation for a specified content item, updating the search index as required.
|
||||
/// </summary>
|
||||
/// <param name="backgroundTaskQueue">The queue used to schedule background indexing tasks.</param>
|
||||
/// <param name="examineUmbracoIndexingHandler">The handler responsible for managing Examine indexing operations.</param>
|
||||
/// <param name="content">The content item to re-index.</param>
|
||||
/// <param name="isPublished">True if the content item is published; otherwise, false.</param>
|
||||
public static void Execute(
|
||||
IBackgroundTaskQueue backgroundTaskQueue,
|
||||
ExamineUmbracoIndexingHandler examineUmbracoIndexingHandler,
|
||||
@@ -281,6 +312,11 @@ internal sealed class ExamineUmbracoIndexingHandler : IUmbracoIndexingHandler
|
||||
private readonly bool _isPublished;
|
||||
private readonly IMedia _media;
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="DeferredReIndexForMedia"/> class.</summary>
|
||||
/// <param name="backgroundTaskQueue">The background task queue to enqueue reindexing tasks.</param>
|
||||
/// <param name="examineUmbracoIndexingHandler">The Examine Umbraco indexing handler instance.</param>
|
||||
/// <param name="media">The media item to be reindexed.</param>
|
||||
/// <param name="isPublished">Indicates whether the media item is published.</param>
|
||||
public DeferredReIndexForMedia(
|
||||
IBackgroundTaskQueue backgroundTaskQueue,
|
||||
ExamineUmbracoIndexingHandler examineUmbracoIndexingHandler,
|
||||
@@ -293,9 +329,21 @@ internal sealed class ExamineUmbracoIndexingHandler : IUmbracoIndexingHandler
|
||||
_isPublished = isPublished;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the process that performs deferred re-indexing of media items in the background.
|
||||
/// This ensures that media content is updated in the search index as needed.
|
||||
/// </summary>
|
||||
public void Execute() =>
|
||||
Execute(_backgroundTaskQueue, _examineUmbracoIndexingHandler, _media, _isPublished);
|
||||
|
||||
/// <summary>
|
||||
/// Performs deferred re-indexing of a media item by enqueuing the operation to a background task queue.
|
||||
/// Ensures that the media item is updated in the search index as required.
|
||||
/// </summary>
|
||||
/// <param name="backgroundTaskQueue">The queue used to schedule background indexing tasks.</param>
|
||||
/// <param name="examineUmbracoIndexingHandler">The handler that manages Examine search indexes.</param>
|
||||
/// <param name="media">The media item to re-index.</param>
|
||||
/// <param name="isPublished">True if the media item is published; otherwise, false.</param>
|
||||
public static void Execute(
|
||||
IBackgroundTaskQueue backgroundTaskQueue,
|
||||
ExamineUmbracoIndexingHandler examineUmbracoIndexingHandler,
|
||||
@@ -332,6 +380,12 @@ internal sealed class ExamineUmbracoIndexingHandler : IUmbracoIndexingHandler
|
||||
private readonly ExamineUmbracoIndexingHandler _examineUmbracoIndexingHandler;
|
||||
private readonly IMember _member;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeferredReIndexForMember"/> class.
|
||||
/// </summary>
|
||||
/// <param name="backgroundTaskQueue">The queue used to schedule background reindexing tasks.</param>
|
||||
/// <param name="examineUmbracoIndexingHandler">The handler responsible for Examine Umbraco indexing operations.</param>
|
||||
/// <param name="member">The member entity to be reindexed.</param>
|
||||
public DeferredReIndexForMember(
|
||||
IBackgroundTaskQueue backgroundTaskQueue,
|
||||
ExamineUmbracoIndexingHandler examineUmbracoIndexingHandler,
|
||||
@@ -342,8 +396,18 @@ internal sealed class ExamineUmbracoIndexingHandler : IUmbracoIndexingHandler
|
||||
_backgroundTaskQueue = backgroundTaskQueue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the deferred re-indexing operation for the specified member in the background task queue.
|
||||
/// This ensures that the member's data is updated in the search index.
|
||||
/// </summary>
|
||||
public void Execute() => Execute(_backgroundTaskQueue, _examineUmbracoIndexingHandler, _member);
|
||||
|
||||
/// <summary>
|
||||
/// Enqueues a deferred re-indexing operation for the specified member, ensuring the member's data is updated in the search index.
|
||||
/// </summary>
|
||||
/// <param name="backgroundTaskQueue">The queue used to schedule background tasks.</param>
|
||||
/// <param name="examineUmbracoIndexingHandler">The handler responsible for managing Examine indexing operations.</param>
|
||||
/// <param name="member">The member whose data should be re-indexed.</param>
|
||||
public static void Execute(
|
||||
IBackgroundTaskQueue backgroundTaskQueue,
|
||||
ExamineUmbracoIndexingHandler examineUmbracoIndexingHandler,
|
||||
@@ -376,6 +440,12 @@ internal sealed class ExamineUmbracoIndexingHandler : IUmbracoIndexingHandler
|
||||
private readonly IReadOnlyCollection<int>? _ids;
|
||||
private readonly bool _keepIfUnpublished;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeferredDeleteIndex"/> class, which represents a deferred deletion operation for a specific item in the index.
|
||||
/// </summary>
|
||||
/// <param name="examineUmbracoIndexingHandler">The parent <see cref="ExamineUmbracoIndexingHandler"/> managing the indexing operations.</param>
|
||||
/// <param name="id">The identifier of the item to be deleted from the index.</param>
|
||||
/// <param name="keepIfUnpublished">If set to <c>true</c>, the item will be retained in the index if it is unpublished; otherwise, it will be deleted.</param>
|
||||
public DeferredDeleteIndex(
|
||||
ExamineUmbracoIndexingHandler examineUmbracoIndexingHandler,
|
||||
int id,
|
||||
@@ -386,6 +456,12 @@ internal sealed class ExamineUmbracoIndexingHandler : IUmbracoIndexingHandler
|
||||
_keepIfUnpublished = keepIfUnpublished;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeferredDeleteIndex"/> class, used to defer deletion of specified items from the index.
|
||||
/// </summary>
|
||||
/// <param name="examineUmbracoIndexingHandler">The parent <see cref="ExamineUmbracoIndexingHandler"/> managing the operation.</param>
|
||||
/// <param name="ids">A read-only collection of item IDs to be deleted from the index.</param>
|
||||
/// <param name="keepIfUnpublished">If <c>true</c>, items will be retained in the index if they are unpublished; otherwise, they will be deleted.</param>
|
||||
public DeferredDeleteIndex(
|
||||
ExamineUmbracoIndexingHandler examineUmbracoIndexingHandler,
|
||||
IReadOnlyCollection<int> ids,
|
||||
@@ -396,6 +472,9 @@ internal sealed class ExamineUmbracoIndexingHandler : IUmbracoIndexingHandler
|
||||
_keepIfUnpublished = keepIfUnpublished;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the deferred deletion of one or more items from the index, based on the provided identifiers.
|
||||
/// </summary>
|
||||
public void Execute()
|
||||
{
|
||||
if (_ids is null)
|
||||
@@ -408,6 +487,12 @@ internal sealed class ExamineUmbracoIndexingHandler : IUmbracoIndexingHandler
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the deferred deletion of a single item from the index.
|
||||
/// </summary>
|
||||
/// <param name="examineUmbracoIndexingHandler">The <see cref="ExamineUmbracoIndexingHandler"/> instance used to perform the deletion.</param>
|
||||
/// <param name="id">The identifier of the item to delete from the index.</param>
|
||||
/// <param name="keepIfUnpublished">If <c>true</c>, the item will be kept in the index if it is unpublished; otherwise, it will be removed.</param>
|
||||
public static void Execute(
|
||||
ExamineUmbracoIndexingHandler examineUmbracoIndexingHandler,
|
||||
int id,
|
||||
@@ -446,6 +531,12 @@ internal sealed class ExamineUmbracoIndexingHandler : IUmbracoIndexingHandler
|
||||
private readonly ExamineUmbracoIndexingHandler _examineUmbracoIndexingHandler;
|
||||
private readonly IPublicAccessService _publicAccessService;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeferredRemoveProtectedContent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="backgroundTaskQueue">The queue used to schedule background tasks for deferred removal operations.</param>
|
||||
/// <param name="examineUmbracoIndexingHandler">The handler responsible for Umbraco Examine indexing operations.</param>
|
||||
/// <param name="publicAccessService">The service used to determine public access permissions for content.</param>
|
||||
public DeferredRemoveProtectedContent(IBackgroundTaskQueue backgroundTaskQueue, ExamineUmbracoIndexingHandler examineUmbracoIndexingHandler, IPublicAccessService publicAccessService)
|
||||
{
|
||||
_backgroundTaskQueue = backgroundTaskQueue;
|
||||
@@ -453,8 +544,17 @@ internal sealed class ExamineUmbracoIndexingHandler : IUmbracoIndexingHandler
|
||||
_publicAccessService = publicAccessService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the deferred removal of protected content from the index.
|
||||
/// </summary>
|
||||
public void Execute() => Execute(_backgroundTaskQueue, _examineUmbracoIndexingHandler, _publicAccessService);
|
||||
|
||||
/// <summary>
|
||||
/// Executes the deferred removal of protected content from the index.
|
||||
/// </summary>
|
||||
/// <param name="backgroundTaskQueue">The queue used to schedule background tasks for deferred execution.</param>
|
||||
/// <param name="examineUmbracoIndexingHandler">The indexing handler responsible for managing Examine indexes in Umbraco.</param>
|
||||
/// <param name="publicAccessService">The service used to determine which content is protected by public access rules.</param>
|
||||
public static void Execute(IBackgroundTaskQueue backgroundTaskQueue, ExamineUmbracoIndexingHandler examineUmbracoIndexingHandler, IPublicAccessService publicAccessService)
|
||||
=> backgroundTaskQueue.QueueBackgroundWorkItem(cancellationToken =>
|
||||
{
|
||||
|
||||
@@ -17,12 +17,27 @@ public class GenericIndexDiagnostics : IIndexDiagnostics
|
||||
private readonly ISet<string> _idOnlyFieldSet = new HashSet<string> { "id" };
|
||||
private readonly IIndex _index;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GenericIndexDiagnostics"/> class with the specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">The index to run diagnostics against.</param>
|
||||
public GenericIndexDiagnostics(IIndex index) => _index = index;
|
||||
|
||||
public int DocumentCount => -1; // unknown
|
||||
/// <summary>
|
||||
/// Gets the count of documents in the index.
|
||||
/// </summary>
|
||||
public int DocumentCount => -1;
|
||||
|
||||
public int FieldCount => -1; // unknown
|
||||
/// <summary>
|
||||
/// Gets the count of fields in the generic index. Returns -1 if unknown.
|
||||
/// </summary>
|
||||
public int FieldCount => -1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a read-only dictionary containing metadata extracted from the index instance.
|
||||
/// The metadata consists of property names and their corresponding values, where the properties are those of the underlying index type, excluding any ignored properties.
|
||||
/// This metadata provides insight into the configuration and state of the index instance.
|
||||
/// </summary>
|
||||
public IReadOnlyDictionary<string, object?> Metadata
|
||||
{
|
||||
get
|
||||
@@ -45,6 +60,12 @@ public class GenericIndexDiagnostics : IIndexDiagnostics
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the index is healthy by checking for its existence and verifying that a basic search query can be executed successfully.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// An <see cref="Attempt{string?}"/> that succeeds if the index is healthy, or fails with an error message if not.
|
||||
/// </returns>
|
||||
public Attempt<string?> IsHealthy()
|
||||
{
|
||||
if (!_index.IndexExists())
|
||||
@@ -64,7 +85,13 @@ public class GenericIndexDiagnostics : IIndexDiagnostics
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets the count of documents in the index.</summary>
|
||||
/// <returns>The number of documents in the index, or -1 if unavailable.</returns>
|
||||
public long GetDocumentCount() => -1L;
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerable collection of field names associated with the index.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> of field names. Currently, this implementation returns an empty collection.</returns>
|
||||
public IEnumerable<string> GetFieldNames() => Enumerable.Empty<string>();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,20 @@ namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
/// </summary>
|
||||
public interface IBackOfficeExamineSearcher
|
||||
{
|
||||
// default implementation to avoid breaking changes falls back to old behaviour
|
||||
/// <summary>
|
||||
/// Searches the back office Examine index using the specified query and parameters.
|
||||
/// </summary>
|
||||
/// <remarks>default implementation to avoid breaking changes falls back to old behaviour</remarks>
|
||||
/// <param name="query">The search query string.</param>
|
||||
/// <param name="entityType">The type of Umbraco entity to search for.</param>
|
||||
/// <param name="pageSize">The maximum number of results to return per page.</param>
|
||||
/// <param name="pageIndex">The zero-based index of the results page to return.</param>
|
||||
/// <param name="totalFound">When this method returns, contains the total number of results matching the query.</param>
|
||||
/// <param name="contentTypeAliases">An optional array of content type aliases to filter the search results; pass <c>null</c> to include all types.</param>
|
||||
/// <param name="trashed">Optional filter to include only trashed (<c>true</c>), only non-trashed (<c>false</c>), or all (<c>null</c>) items.</param>
|
||||
/// <param name="searchFrom">An optional starting point (node ID or path) for the search; pass <c>null</c> to search from the root.</param>
|
||||
/// <param name="ignoreUserStartNodes">If <c>true</c>, ignores user start nodes when searching; otherwise, respects user permissions.</param>
|
||||
/// <returns>An enumerable collection of <see cref="ISearchResult"/> objects matching the query and filters.</returns>
|
||||
IEnumerable<ISearchResult> Search(
|
||||
string query,
|
||||
UmbracoEntityTypes entityType,
|
||||
|
||||
@@ -22,11 +22,32 @@ public interface IContentValueSetValidator : IValueSetValidator
|
||||
/// </summary>
|
||||
bool SupportProtectedContent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the identifier of the parent content item, if available.
|
||||
/// </summary>
|
||||
int? ParentId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified path is valid for the given category.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to validate.</param>
|
||||
/// <param name="category">The category to validate the path against.</param>
|
||||
/// <returns><c>true</c> if the path is valid for the category; otherwise, <c>false</c>.</returns>
|
||||
bool ValidatePath(string path, string category);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified path and category refer to a recycle bin.
|
||||
/// </summary>
|
||||
/// <param name="path">The content path to check.</param>
|
||||
/// <param name="category">The content category to check.</param>
|
||||
/// <returns><c>true</c> if the path is valid (not in the recycle bin); otherwise, <c>false</c>.</returns>
|
||||
bool ValidateRecycleBin(string path, string category);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the content at the specified path and category should be considered protected.
|
||||
/// </summary>
|
||||
/// <param name="path">The path of the content to check.</param>
|
||||
/// <param name="category">The category of the content to check.</param>
|
||||
/// <returns><c>true</c> if the content passes protection validation (is not protected or protection checks do not apply); otherwise, <c>false</c>.</returns>
|
||||
bool ValidateProtectedContent(string path, string category);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
internal interface IDeferredAction
|
||||
{
|
||||
/// <summary>
|
||||
/// Executes the action represented by this deferred action instance.
|
||||
/// </summary>
|
||||
void Execute();
|
||||
}
|
||||
|
||||
+8
-1
@@ -1,8 +1,15 @@
|
||||
using Examine;
|
||||
using Examine;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a contract for building field definitions used in the Delivery API content index.
|
||||
/// </summary>
|
||||
public interface IDeliveryApiContentIndexFieldDefinitionBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// Builds a collection of field definitions for the Delivery API content index.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="FieldDefinitionCollection"/> containing the field definitions for the index.</returns>
|
||||
FieldDefinitionCollection Build();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
internal interface IDeliveryApiContentIndexHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Enumerates all applicable descendant content items of the specified root content ID, invoking the provided action for each batch of descendants.
|
||||
/// </summary>
|
||||
/// <param name="rootContentId">The ID of the root content item from which to start enumerating descendants.</param>
|
||||
/// <param name="actionToPerform">An action to perform on each batch (array) of descendant <see cref="IContent"/> items.</param>
|
||||
void EnumerateApplicableDescendantsForContentIndex(int rootContentId, Action<IContent[]> actionToPerform);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a contract for building value sets used in the Delivery API content index.
|
||||
/// </summary>
|
||||
public interface IDeliveryApiContentIndexValueSetBuilder : IValueSetBuilder<IContent>
|
||||
{
|
||||
}
|
||||
|
||||
@@ -7,5 +7,10 @@ namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
/// </summary>
|
||||
public interface IIndexDiagnosticsFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates an <see cref="IIndexDiagnostics"/> instance for the specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">The index to create diagnostics for.</param>
|
||||
/// <returns>An <see cref="IIndexDiagnostics"/> instance.</returns>
|
||||
IIndexDiagnostics Create(IIndex index);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ using Examine;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the contract for classes responsible for populating search indexes with data.
|
||||
/// Implementations of this interface handle the logic required to add or update content in an index.
|
||||
/// </summary>
|
||||
public interface IIndexPopulator
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -2,11 +2,24 @@ using Examine;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the configuration settings used to define and customize an Umbraco Examine index.
|
||||
/// </summary>
|
||||
public interface IUmbracoIndexConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Umbraco.Cms.Infrastructure.Examine.IContentValueSetValidator" /> used to validate content value sets before they are indexed.
|
||||
/// </summary>
|
||||
/// <returns>An instance of <see cref="Umbraco.Cms.Infrastructure.Examine.IContentValueSetValidator" /> for validating content value sets.</returns>
|
||||
IContentValueSetValidator GetContentValueSetValidator();
|
||||
|
||||
/// <summary>Gets the validator used for published content value sets.</summary>
|
||||
/// <returns>An <see cref="IContentValueSetValidator"/> instance for validating published content value sets.</returns>
|
||||
IContentValueSetValidator GetPublishedContentValueSetValidator();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="IValueSetValidator"/> used to validate value sets for members.
|
||||
/// </summary>
|
||||
/// <returns>The validator for member value sets.</returns>
|
||||
IValueSetValidator GetMemberValueSetValidator();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an interface for the Umbraco member index within the Examine search provider, defining the contract for member indexing functionality.
|
||||
/// </summary>
|
||||
public interface IUmbracoMemberIndex : IUmbracoIndex
|
||||
{
|
||||
}
|
||||
|
||||
@@ -11,8 +11,9 @@ public interface IUmbracoTreeSearcherFields
|
||||
IEnumerable<string> GetBackOfficeFields();
|
||||
|
||||
/// <summary>
|
||||
/// The additional index fields that are searched on in the back office for member entities.
|
||||
/// Gets the additional index fields that are searched in the back office for member entities.
|
||||
/// </summary>
|
||||
/// <returns>An enumerable collection of index field names used for searching member entities in the back office.</returns>
|
||||
IEnumerable<string> GetBackOfficeMembersFields();
|
||||
|
||||
/// <summary>
|
||||
@@ -21,15 +22,32 @@ public interface IUmbracoTreeSearcherFields
|
||||
IEnumerable<string> GetBackOfficeMediaFields();
|
||||
|
||||
/// <summary>
|
||||
/// The additional index fields that are searched on in the back office for document entities.
|
||||
/// Returns the additional index fields that are searched in the back office for document entities.
|
||||
/// </summary>
|
||||
/// <returns>An enumerable collection of index field names used for searching document entities in the back office.</returns>
|
||||
IEnumerable<string> GetBackOfficeDocumentFields();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the set of field names that should be loaded for back office operations.
|
||||
/// </summary>
|
||||
/// <returns>A set of field names required for back office functionality.</returns>
|
||||
ISet<string> GetBackOfficeFieldsToLoad();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the set of field names to be loaded for back office member search or display.
|
||||
/// </summary>
|
||||
/// <returns>A set of field names relevant to back office members.</returns>
|
||||
ISet<string> GetBackOfficeMembersFieldsToLoad();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the set of document field names that should be loaded when retrieving documents for the back office.
|
||||
/// </summary>
|
||||
/// <returns>A set of field names to load for back office document retrieval.</returns>
|
||||
ISet<string> GetBackOfficeDocumentFieldsToLoad();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the set of media fields that should be loaded for back office search or indexing operations.
|
||||
/// </summary>
|
||||
/// <returns>A set of strings representing the names of media fields to load for back office operations.</returns>
|
||||
ISet<string> GetBackOfficeMediaFieldsToLoad();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,11 @@ namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
/// </summary>
|
||||
public class IndexDiagnosticsFactory : IIndexDiagnosticsFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates an <see cref="IIndexDiagnostics"/> instance for the given <see cref="IIndex"/>.
|
||||
/// </summary>
|
||||
/// <param name="index">The index to create diagnostics for.</param>
|
||||
/// <returns>An <see cref="IIndexDiagnostics"/> instance associated with the provided index.</returns>
|
||||
public virtual IIndexDiagnostics Create(IIndex index)
|
||||
{
|
||||
if (index is not IIndexDiagnostics indexDiag)
|
||||
|
||||
@@ -10,6 +10,11 @@ namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
public abstract class IndexPopulator<TIndex> : IndexPopulator
|
||||
where TIndex : IIndex
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines whether the specified index is registered.
|
||||
/// </summary>
|
||||
/// <param name="index">The index to check for registration.</param>
|
||||
/// <returns>True if the index is registered; otherwise, false.</returns>
|
||||
public override bool IsRegistered(IIndex index)
|
||||
{
|
||||
if (base.IsRegistered(index))
|
||||
@@ -25,15 +30,29 @@ public abstract class IndexPopulator<TIndex> : IndexPopulator
|
||||
return IsRegistered(casted);
|
||||
}
|
||||
|
||||
/// <summary>Determines whether the specified index is registered.</summary>
|
||||
/// <param name="index">The index to check for registration.</param>
|
||||
/// <returns><c>true</c> if the index is registered; otherwise, <c>false</c>.</returns>
|
||||
public virtual bool IsRegistered(TIndex index) => true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides functionality to populate and manage Examine indexes with data in Umbraco.
|
||||
/// </summary>
|
||||
public abstract class IndexPopulator : IIndexPopulator
|
||||
{
|
||||
private readonly ConcurrentHashSet<string> _registeredIndexes = new();
|
||||
|
||||
/// <summary>Determines whether the specified index is registered.</summary>
|
||||
/// <param name="index">The index to check for registration.</param>
|
||||
/// <returns>True if the index is registered; otherwise, false.</returns>
|
||||
public virtual bool IsRegistered(IIndex index) => _registeredIndexes.Contains(index.Name);
|
||||
|
||||
/// <summary>
|
||||
/// Populates the specified indexes by initializing or updating their contents as required.
|
||||
/// Only indexes that are registered will be populated.
|
||||
/// </summary>
|
||||
/// <param name="indexes">The indexes to populate.</param>
|
||||
public void Populate(params IIndex[] indexes) => PopulateIndexes(indexes.Where(IsRegistered).ToList());
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -21,6 +21,12 @@ public class MediaIndexPopulator : IndexPopulator<IUmbracoContentIndex>
|
||||
|
||||
private IndexingSettings _indexingSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MediaIndexPopulator"/> class, which is responsible for populating the media index in Examine.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger used to record diagnostic and operational information for the media index population process.</param>
|
||||
/// <param name="mediaService">The service used to access and manage media items in Umbraco.</param>
|
||||
/// <param name="mediaValueSetBuilder">The builder that constructs value sets from media items for indexing.</param>
|
||||
[Obsolete("Please use the non-obsolete constructor. Scheduled for removal in Umbraco 19.")]
|
||||
public MediaIndexPopulator(ILogger<MediaIndexPopulator> logger, IMediaService mediaService, IValueSetBuilder<IMedia> mediaValueSetBuilder)
|
||||
: this(logger, null, mediaService, mediaValueSetBuilder, StaticServiceProvider.Instance.GetRequiredService<IOptionsMonitor<IndexingSettings>>())
|
||||
@@ -28,13 +34,24 @@ public class MediaIndexPopulator : IndexPopulator<IUmbracoContentIndex>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor to lookup all content data
|
||||
/// Initializes a new instance of the <see cref="MediaIndexPopulator"/> class, used to index all media content data.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger instance used for logging operations.</param>
|
||||
/// <param name="mediaService">The media service used to access media items.</param>
|
||||
/// <param name="mediaValueSetBuilder">The value set builder for constructing indexable values from media items.</param>
|
||||
/// <param name="indexingSettings">The indexing settings configuration.</param>
|
||||
public MediaIndexPopulator(ILogger<MediaIndexPopulator> logger, IMediaService mediaService, IValueSetBuilder<IMedia> mediaValueSetBuilder, IOptionsMonitor<IndexingSettings> indexingSettings)
|
||||
: this(logger, null, mediaService, mediaValueSetBuilder, indexingSettings)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MediaIndexPopulator"/> class, which is responsible for populating the media index in Examine.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger used for logging operations within the populator.</param>
|
||||
/// <param name="parentId">An optional parent ID to filter which media items are indexed. If <c>null</c>, all media items are considered.</param>
|
||||
/// <param name="mediaService">The service used to access and manage media data.</param>
|
||||
/// <param name="mediaValueSetBuilder">The builder used to create value sets for media items to be indexed.</param>
|
||||
[Obsolete("Please use the non-obsolete constructor. Scheduled for removal in Umbraco 19.")]
|
||||
public MediaIndexPopulator(ILogger<MediaIndexPopulator> logger, int? parentId, IMediaService mediaService, IValueSetBuilder<IMedia> mediaValueSetBuilder)
|
||||
: this(logger, parentId, mediaService, mediaValueSetBuilder, StaticServiceProvider.Instance.GetRequiredService<IOptionsMonitor<IndexingSettings>>())
|
||||
@@ -42,8 +59,13 @@ public class MediaIndexPopulator : IndexPopulator<IUmbracoContentIndex>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Optional constructor allowing specifying custom query parameters
|
||||
/// Initializes a new instance of the <see cref="MediaIndexPopulator"/> class, allowing specification of custom query parameters for media indexing.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger used for logging operations within the media index populator.</param>
|
||||
/// <param name="parentId">An optional parent media item ID to filter which media items are indexed.</param>
|
||||
/// <param name="mediaService">The service used to access and manage media items.</param>
|
||||
/// <param name="mediaValueSetBuilder">Builds value sets for media items to be indexed.</param>
|
||||
/// <param name="indexingSettings">Monitors configuration settings related to indexing.</param>
|
||||
public MediaIndexPopulator(ILogger<MediaIndexPopulator> logger, int? parentId, IMediaService mediaService, IValueSetBuilder<IMedia> mediaValueSetBuilder, IOptionsMonitor<IndexingSettings> indexingSettings)
|
||||
{
|
||||
_logger = logger;
|
||||
|
||||
@@ -10,6 +10,11 @@ using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
/// <summary>
|
||||
/// Responsible for constructing <see cref="ValueSet"/> instances representing media items
|
||||
/// for indexing by the Examine search engine in Umbraco.
|
||||
/// This builder extracts relevant properties from media entities to facilitate efficient searching and retrieval.
|
||||
/// </summary>
|
||||
public class MediaValueSetBuilder : BaseValueSetBuilder<IMedia>
|
||||
{
|
||||
private readonly ContentSettings _contentSettings;
|
||||
@@ -19,6 +24,16 @@ public class MediaValueSetBuilder : BaseValueSetBuilder<IMedia>
|
||||
private readonly UrlSegmentProviderCollection _urlSegmentProviders;
|
||||
private readonly IUserService _userService;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Infrastructure.Examine.MediaValueSetBuilder"/> class.
|
||||
/// </summary>
|
||||
/// <param name="propertyEditors">A collection of <see cref="PropertyEditorCollection"/> used to manage property editors for media items.</param>
|
||||
/// <param name="urlSegmentProviders">A collection of <see cref="UrlSegmentProviderCollection"/> used to generate URL segments for media items.</param>
|
||||
/// <param name="mediaUrlGenerators">A collection of <see cref="MediaUrlGeneratorCollection"/> used to generate URLs for media items.</param>
|
||||
/// <param name="userService">An implementation of <see cref="IUserService"/> for accessing user-related operations.</param>
|
||||
/// <param name="shortStringHelper">An implementation of <see cref="IShortStringHelper"/> for string manipulation and formatting.</param>
|
||||
/// <param name="contentSettings">The <see cref="IOptions{ContentSettings}"/> providing configuration options for content.</param>
|
||||
/// <param name="contentTypeService">An implementation of <see cref="IContentTypeService"/> for accessing content type information.</param>
|
||||
public MediaValueSetBuilder(
|
||||
PropertyEditorCollection propertyEditors,
|
||||
UrlSegmentProviderCollection urlSegmentProviders,
|
||||
|
||||
@@ -4,11 +4,20 @@ using Umbraco.Cms.Core.Services;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
/// <summary>
|
||||
/// Populates and maintains the member index used by the Examine search engine in Umbraco.
|
||||
/// This ensures that member data is searchable and kept up to date within the index.
|
||||
/// </summary>
|
||||
public class MemberIndexPopulator : IndexPopulator<IUmbracoMemberIndex>
|
||||
{
|
||||
private readonly IMemberService _memberService;
|
||||
private readonly IValueSetBuilder<IMember> _valueSetBuilder;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Infrastructure.Examine.MemberIndexPopulator"/> class.
|
||||
/// </summary>
|
||||
/// <param name="memberService">Service for accessing and managing member data.</param>
|
||||
/// <param name="valueSetBuilder">Builder for creating value sets from member entities.</param>
|
||||
public MemberIndexPopulator(IMemberService memberService, IValueSetBuilder<IMember> valueSetBuilder)
|
||||
{
|
||||
_memberService = memberService;
|
||||
|
||||
@@ -6,10 +6,18 @@ using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
/// <summary>
|
||||
/// Provides functionality to build value sets for member entities, enabling them to be indexed by Examine.
|
||||
/// </summary>
|
||||
public class MemberValueSetBuilder : BaseValueSetBuilder<IMember>
|
||||
{
|
||||
private readonly IContentTypeService _contentTypeService;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MemberValueSetBuilder"/> class with the specified property editors and content type service.
|
||||
/// </summary>
|
||||
/// <param name="propertyEditors">A <see cref="PropertyEditorCollection"/> representing the collection of property editors to use.</param>
|
||||
/// <param name="contentTypeService">An <see cref="IContentTypeService"/> used to access content type information.</param>
|
||||
public MemberValueSetBuilder(PropertyEditorCollection propertyEditors, IContentTypeService contentTypeService)
|
||||
: base(propertyEditors, false)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
/// <summary>
|
||||
/// Provides validation logic for member value sets during the Examine indexing process in Umbraco.
|
||||
/// </summary>
|
||||
public class MemberValueSetValidator : ValueSetValidator
|
||||
{
|
||||
/// <summary>
|
||||
@@ -13,16 +16,31 @@ public class MemberValueSetValidator : ValueSetValidator
|
||||
|
||||
private static readonly IEnumerable<string> _validCategories = new[] { IndexTypes.Member };
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MemberValueSetValidator"/> class, which is used to validate value sets for members in Examine.
|
||||
/// </summary>
|
||||
public MemberValueSetValidator()
|
||||
: base(null, null, DefaultMemberIndexFields, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Infrastructure.Examine.MemberValueSetValidator"/> class.
|
||||
/// </summary>
|
||||
/// <param name="includeItemTypes">An optional collection of item types to include for validation. If <c>null</c>, all item types are included unless excluded by <paramref name="excludeItemTypes"/>.</param>
|
||||
/// <param name="excludeItemTypes">An optional collection of item types to exclude from validation. If <c>null</c>, no item types are excluded.</param>
|
||||
public MemberValueSetValidator(IEnumerable<string>? includeItemTypes, IEnumerable<string>? excludeItemTypes)
|
||||
: base(includeItemTypes, excludeItemTypes, DefaultMemberIndexFields, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Infrastructure.Examine.MemberValueSetValidator"/> class.
|
||||
/// </summary>
|
||||
/// <param name="includeItemTypes">Item types to include in validation, or <c>null</c> to include all.</param>
|
||||
/// <param name="excludeItemTypes">Item types to exclude from validation, or <c>null</c> to exclude none.</param>
|
||||
/// <param name="includeFields">Fields to include in validation, or <c>null</c> to include all.</param>
|
||||
/// <param name="excludeFields">Fields to exclude from validation, or <c>null</c> to exclude none.</param>
|
||||
public MemberValueSetValidator(IEnumerable<string>? includeItemTypes, IEnumerable<string>? excludeItemTypes, IEnumerable<string>? includeFields, IEnumerable<string>? excludeFields)
|
||||
: base(includeItemTypes, excludeItemTypes, includeFields, excludeFields)
|
||||
{
|
||||
|
||||
@@ -3,8 +3,25 @@ using Umbraco.Cms.Core.Models.ContentEditing;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a no-operation (noop) implementation of the back office Examine searcher, which performs no search actions.
|
||||
/// This can be used as a placeholder or default when search functionality is not required.
|
||||
/// </summary>
|
||||
public class NoopBackOfficeExamineSearcher : IBackOfficeExamineSearcher
|
||||
{
|
||||
/// <summary>
|
||||
/// Simulates a search against the back office examine index, but always returns no results.
|
||||
/// </summary>
|
||||
/// <param name="query">The search query string.</param>
|
||||
/// <param name="entityType">The type of Umbraco entity to search for.</param>
|
||||
/// <param name="pageSize">The number of results to return per page.</param>
|
||||
/// <param name="pageIndex">The index of the page of results to return.</param>
|
||||
/// <param name="totalFound">Outputs the total number of results found (always zero).</param>
|
||||
/// <param name="contentTypeAliases">Optional array of content type aliases to filter the search.</param>
|
||||
/// <param name="trashed">Optional filter to include trashed items.</param>
|
||||
/// <param name="searchFrom">Optional starting point for the search.</param>
|
||||
/// <param name="ignoreUserStartNodes">Whether to ignore user start nodes in the search.</param>
|
||||
/// <returns>An empty enumerable, as this implementation does not perform any search.</returns>
|
||||
public IEnumerable<ISearchResult> Search(
|
||||
string query,
|
||||
UmbracoEntityTypes entityType,
|
||||
|
||||
@@ -4,21 +4,42 @@ namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
internal sealed class NoopExamineManager : IExamineManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Releases resources used by the <see cref="NoopExamineManager"/>. This implementation does nothing.
|
||||
/// </summary>
|
||||
public void Dispose() {}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to get an index by name.
|
||||
/// </summary>
|
||||
/// <param name="indexName">The name of the index to retrieve.</param>
|
||||
/// <param name="index">When this method returns, contains the index associated with the specified name, if the index is found; otherwise, null.</param>
|
||||
/// <returns><c>true</c> if the index was found; otherwise, <c>false</c>.</returns>
|
||||
public bool TryGetIndex(string indexName, out IIndex index)
|
||||
{
|
||||
index = null!;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to get a searcher by name.
|
||||
/// </summary>
|
||||
/// <param name="searcherName">The name of the searcher to retrieve.</param>
|
||||
/// <param name="searcher">When this method returns, contains the searcher associated with the specified name, if the searcher is found; otherwise, null.</param>
|
||||
/// <returns><c>true</c> if the searcher was found; otherwise, <c>false</c>.</returns>
|
||||
public bool TryGetSearcher(string searcherName, out ISearcher searcher)
|
||||
{
|
||||
searcher = null!;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an empty collection of indexes.
|
||||
/// </summary>
|
||||
public IEnumerable<IIndex> Indexes => Array.Empty<IIndex>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of registered searchers, which is always empty for the <see cref="NoopExamineManager"/>.
|
||||
/// </summary>
|
||||
public IEnumerable<ISearcher> RegisteredSearchers => Array.Empty<ISearcher>();
|
||||
}
|
||||
|
||||
@@ -2,11 +2,36 @@ namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
internal sealed class NoopIndexRebuilder : IIndexRebuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates whether the specified index can be rebuilt. Always returns <c>false</c> because rebuilding is not supported by this implementation.
|
||||
/// </summary>
|
||||
/// <param name="indexName">The name of the index to check.</param>
|
||||
/// <returns><c>false</c> in all cases.</returns>
|
||||
public bool CanRebuild(string indexName) => false;
|
||||
|
||||
/// <summary>
|
||||
/// Performs no action when called; this method is a no-operation (noop) implementation for rebuilding the specified index.
|
||||
/// </summary>
|
||||
/// <param name="indexName">The name of the index to rebuild.</param>
|
||||
/// <param name="delay">An optional delay before starting the rebuild.</param>
|
||||
/// <param name="useBackgroundThread">Indicates whether to use a background thread for the rebuild.</param>
|
||||
public void RebuildIndex(string indexName, TimeSpan? delay = null, bool useBackgroundThread = true) {}
|
||||
|
||||
/// <summary>
|
||||
/// Simulates rebuilding indexes but intentionally performs no operation.
|
||||
/// This method is typically used as a placeholder where index rebuilding is not required.
|
||||
/// </summary>
|
||||
/// <param name="onlyEmptyIndexes">Indicates whether to rebuild only empty indexes (ignored).</param>
|
||||
/// <param name="delay">An optional delay before starting the rebuild (ignored).</param>
|
||||
/// <param name="useBackgroundThread">Indicates whether to use a background thread for the rebuild (ignored).</param>
|
||||
public void RebuildIndexes(bool onlyEmptyIndexes, TimeSpan? delay = null, bool useBackgroundThread = true) {}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously determines whether the specified index is currently rebuilding.
|
||||
/// </summary>
|
||||
/// <param name="indexName">The name of the index to check.</param>
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous operation. The task result is always <c>false</c> in this implementation, indicating the index is never rebuilding.
|
||||
/// </returns>
|
||||
public Task<bool> IsRebuildingAsync(string indexName) => Task.FromResult(false);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,13 @@ namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
/// </remarks>
|
||||
public class PublishedContentIndexPopulator : ContentIndexPopulator
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PublishedContentIndexPopulator"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger used for logging information and errors.</param>
|
||||
/// <param name="contentService">The service used to manage Umbraco content.</param>
|
||||
/// <param name="umbracoDatabaseFactory">The factory for creating Umbraco database instances.</param>
|
||||
/// <param name="contentValueSetBuilder">The builder for creating value sets from published content.</param>
|
||||
[Obsolete("Please use the non-obsolete constructor. Scheduled for removal in Umbraco 19.")]
|
||||
public PublishedContentIndexPopulator(
|
||||
ILogger<PublishedContentIndexPopulator> logger,
|
||||
@@ -27,6 +34,14 @@ public class PublishedContentIndexPopulator : ContentIndexPopulator
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PublishedContentIndexPopulator"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The <see cref="ILogger{PublishedContentIndexPopulator}"/> used for logging operations.</param>
|
||||
/// <param name="contentService">The <see cref="IContentService"/> used to access and manage content items.</param>
|
||||
/// <param name="umbracoDatabaseFactory">The <see cref="IUmbracoDatabaseFactory"/> used to create Umbraco database connections.</param>
|
||||
/// <param name="contentValueSetBuilder">The <see cref="IPublishedContentValueSetBuilder"/> responsible for building value sets for published content.</param>
|
||||
/// <param name="indexingSettings">The <see cref="IOptionsMonitor{IndexingSettings}"/> providing access to indexing configuration settings.</param>
|
||||
public PublishedContentIndexPopulator(
|
||||
ILogger<PublishedContentIndexPopulator> logger,
|
||||
IContentService contentService,
|
||||
|
||||
@@ -28,6 +28,12 @@ public sealed class RebuildOnStartupHandler : INotificationHandler<UmbracoReques
|
||||
private readonly ISyncBootStateAccessor _syncBootStateAccessor;
|
||||
private readonly IIndexRebuilder _indexRebuilder;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Infrastructure.Examine.RebuildOnStartupHandler"/> class, responsible for handling index rebuilds during application startup.
|
||||
/// </summary>
|
||||
/// <param name="syncBootStateAccessor">Provides access to the application's synchronous boot state, used to determine if the system is ready for index rebuilding.</param>
|
||||
/// <param name="indexRebuilder">The service responsible for rebuilding Examine indexes.</param>
|
||||
/// <param name="runtimeState">Provides information about the current runtime state of the Umbraco application.</param>
|
||||
public RebuildOnStartupHandler(
|
||||
ISyncBootStateAccessor syncBootStateAccessor,
|
||||
IIndexRebuilder indexRebuilder,
|
||||
|
||||
@@ -5,6 +5,9 @@ using Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
namespace Umbraco.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Contains extension methods that enhance or simplify working with Umbraco Examine.
|
||||
/// </summary>
|
||||
public static partial class UmbracoExamineExtensions
|
||||
{
|
||||
/// <summary>
|
||||
@@ -66,6 +69,12 @@ public static partial class UmbracoExamineExtensions
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extends the specified <see cref="IQuery"/> to filter results by the given integer ID.
|
||||
/// </summary>
|
||||
/// <param name="query">The query to extend.</param>
|
||||
/// <param name="id">The integer ID value to filter by.</param>
|
||||
/// <returns>An <see cref="IBooleanOperation"/> representing the query filtered by ID.</returns>
|
||||
public static IBooleanOperation Id(this IQuery query, int id)
|
||||
{
|
||||
IBooleanOperation? fieldQuery = query.Id(id.ToInvariantString());
|
||||
|
||||
@@ -2,6 +2,9 @@ using Examine;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
/// <summary>
|
||||
/// Provides constant field names used by Umbraco for indexing and searching content with Examine.
|
||||
/// </summary>
|
||||
public static class UmbracoExamineFieldNames
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -4,8 +4,16 @@ using IScopeProvider = Umbraco.Cms.Infrastructure.Scoping.IScopeProvider;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the configuration settings for an Umbraco Examine index.
|
||||
/// </summary>
|
||||
public class UmbracoIndexConfig : IUmbracoIndexConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UmbracoIndexConfig"/> class with the specified public access service and scope provider.
|
||||
/// </summary>
|
||||
/// <param name="publicAccessService">Service used to manage public access restrictions for content.</param>
|
||||
/// <param name="scopeProvider">Provider for managing database transaction scopes.</param>
|
||||
public UmbracoIndexConfig(IPublicAccessService publicAccessService, IScopeProvider scopeProvider)
|
||||
{
|
||||
ScopeProvider = scopeProvider;
|
||||
@@ -16,9 +24,19 @@ public class UmbracoIndexConfig : IUmbracoIndexConfig
|
||||
|
||||
protected IScopeProvider ScopeProvider { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a content value set validator configured for use with content indexing.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// An instance of <see cref="IContentValueSetValidator"/> initialized with the current configuration and services.
|
||||
/// </returns>
|
||||
public IContentValueSetValidator GetContentValueSetValidator() =>
|
||||
new ContentValueSetValidator(false, true, PublicAccessService, ScopeProvider, null, null, null);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IContentValueSetValidator"/> instance used to validate published content value sets.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="IContentValueSetValidator"/> configured for published content.</returns>
|
||||
public IContentValueSetValidator GetPublishedContentValueSetValidator() =>
|
||||
new ContentValueSetValidator(true, false, PublicAccessService, ScopeProvider, null, null, null);
|
||||
|
||||
|
||||
@@ -8,6 +8,13 @@ namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
/// </summary>
|
||||
public class ValueSetValidator : IValueSetValidator
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ValueSetValidator"/> class.
|
||||
/// </summary>
|
||||
/// <param name="includeItemTypes">Item types to include during validation.</param>
|
||||
/// <param name="excludeItemTypes">Item types to exclude from validation.</param>
|
||||
/// <param name="includeFields">Fields to include during validation.</param>
|
||||
/// <param name="excludeFields">Fields to exclude from validation.</param>
|
||||
public ValueSetValidator(
|
||||
IEnumerable<string>? includeItemTypes,
|
||||
IEnumerable<string>? excludeItemTypes,
|
||||
@@ -55,6 +62,14 @@ public class ValueSetValidator : IValueSetValidator
|
||||
|
||||
protected virtual IEnumerable<string>? ValidIndexCategories { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Validates the specified <see cref="ValueSet"/> against the configured inclusion and exclusion rules for categories, item types, and fields.
|
||||
/// </summary>
|
||||
/// <param name="valueSet">The <see cref="ValueSet"/> to validate and filter.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="ValueSetValidationResult"/> indicating whether the value set is valid for indexing, and containing a filtered <see cref="ValueSet"/> with only the allowed fields if valid.
|
||||
/// If the value set does not meet the validation criteria, the result will indicate failure and contain the original value set.
|
||||
/// </returns>
|
||||
public virtual ValueSetValidationResult Validate(ValueSet valueSet)
|
||||
{
|
||||
/* Notes on status on the result:
|
||||
|
||||
@@ -1,15 +1,30 @@
|
||||
using Umbraco.Cms.Core.Models.DeliveryApi;
|
||||
using Umbraco.Cms.Core.Models.DeliveryApi;
|
||||
using Umbraco.Cms.Core.PropertyEditors.ValueConverters;
|
||||
|
||||
namespace Umbraco.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Provides extension methods for working with images in the Umbraco Delivery API.
|
||||
/// </summary>
|
||||
public static class DeliveryApiImageExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the focal point of the specified <see cref="ImageCropperValue"/> if it exists.
|
||||
/// </summary>
|
||||
/// <param name="imageCropperValue">The image cropper value to extract the focal point from.</param>
|
||||
/// <returns>The <see cref="ImageFocalPoint"/> if a focal point is defined; otherwise, <c>null</c>.</returns>
|
||||
public static ImageFocalPoint? GetImageFocalPoint(this ImageCropperValue imageCropperValue)
|
||||
=> imageCropperValue.FocalPoint is not null
|
||||
? new ImageFocalPoint(imageCropperValue.FocalPoint.Left, imageCropperValue.FocalPoint.Top)
|
||||
: null;
|
||||
|
||||
/// <summary>
|
||||
/// Returns a collection of <see cref="ImageCrop"/> objects extracted from the specified <see cref="ImageCropperValue"/>.
|
||||
/// </summary>
|
||||
/// <param name="imageCropperValue">The <see cref="ImageCropperValue"/> instance from which to extract image crops.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="IEnumerable{T}"/> of <see cref="ImageCrop"/> representing the crops defined in the image cropper value, or <c>null</c> if no crops are present.
|
||||
/// </returns>
|
||||
public static IEnumerable<ImageCrop>? GetImageCrops(this ImageCropperValue imageCropperValue)
|
||||
=> imageCropperValue.Crops?.Select(crop => new ImageCrop(
|
||||
crop.Alias,
|
||||
|
||||
@@ -6,6 +6,15 @@ namespace Umbraco.Cms.Infrastructure.Extensions;
|
||||
|
||||
internal static class EmailMessageExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts an <see cref="EmailMessage"/> to a <see cref="MimeMessage"/>, including all recipients, subject, body, and attachments.
|
||||
/// If the <paramref name="mailMessage"/> does not specify a From address, the <paramref name="configuredFromAddress"/> is used as the sender.
|
||||
/// </summary>
|
||||
/// <param name="mailMessage">The email message to convert.</param>
|
||||
/// <param name="configuredFromAddress">The default sender address to use if <paramref name="mailMessage"/> does not specify one.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="MimeMessage"/> representing the converted email message, including all recipients, subject, body (as HTML or plain text), and any attachments.
|
||||
/// </returns>
|
||||
public static MimeMessage ToMimeMessage(this EmailMessage mailMessage, string configuredFromAddress)
|
||||
{
|
||||
var fromEmail = string.IsNullOrEmpty(mailMessage.From) ? configuredFromAddress : mailMessage.From;
|
||||
@@ -51,6 +60,15 @@ internal static class EmailMessageExtensions
|
||||
return messageToSend;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts an <see cref="EmailMessage"/> to a <see cref="NotificationEmailModel"/>.
|
||||
/// If the <paramref name="emailMessage"/>'s from address is not set or is empty, the <paramref name="configuredFromAddress"/> is used as the sender address.
|
||||
/// </summary>
|
||||
/// <param name="emailMessage">The email message to convert.</param>
|
||||
/// <param name="configuredFromAddress">The fallback sender address to use if the email message's from address is not specified.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="NotificationEmailModel"/> representing the notification email, with all recipients, subject, body, attachments, and sender address appropriately set.
|
||||
/// </returns>
|
||||
public static NotificationEmailModel ToNotificationEmail(
|
||||
this EmailMessage emailMessage,
|
||||
string? configuredFromAddress)
|
||||
|
||||
@@ -3,6 +3,9 @@ using Umbraco.Cms.Core.Packaging;
|
||||
|
||||
namespace Umbraco.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Contains extension methods to assist with loading and managing infrastructure-related types in Umbraco.
|
||||
/// </summary>
|
||||
public static class InfrastuctureTypeLoaderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -4,6 +4,14 @@ namespace Umbraco.Extensions;
|
||||
|
||||
internal static class InstanceIdentifiableExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets debug information for the specified <see cref="IInstanceIdentifiable"/> instance, including a shortened instance ID and the thread ID where it was created.
|
||||
/// </summary>
|
||||
/// <param name="instance">The instance to get debug information from.</param>
|
||||
/// <returns>
|
||||
/// A string containing debug information about the instance in the format <c>(id: [first 8 chars of InstanceId] from thread: [CreatedThreadId])</c>,
|
||||
/// or <c>"(NULL)"</c> if the instance is <c>null</c>.
|
||||
/// </returns>
|
||||
public static string GetDebugInfo(this IInstanceIdentifiable? instance)
|
||||
{
|
||||
if (instance == null)
|
||||
|
||||
@@ -3,6 +3,9 @@ using Umbraco.Cms.Core.PropertyEditors.ValueConverters;
|
||||
|
||||
namespace Umbraco.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Provides extension methods for configuring and working with Media Picker 3 settings in Umbraco.
|
||||
/// </summary>
|
||||
public static class MediaPicker3ConfigurationExtensions
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -2,8 +2,16 @@ using Umbraco.Cms.Core.Scoping;
|
||||
|
||||
namespace Umbraco.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Provides extension methods for managing Umbraco scope lifecycles and operations.
|
||||
/// </summary>
|
||||
public static class ScopeExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Acquires read locks on the specified lock IDs within the given scope.
|
||||
/// </summary>
|
||||
/// <param name="scope">The scope on which to acquire the read locks.</param>
|
||||
/// <param name="lockIds">The collection of lock IDs to acquire read locks for.</param>
|
||||
public static void ReadLock(this IScope scope, ICollection<int> lockIds)
|
||||
{
|
||||
foreach (var lockId in lockIds)
|
||||
@@ -12,6 +20,11 @@ public static class ScopeExtensions
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Acquires write locks on the specified lock IDs within the given scope.
|
||||
/// </summary>
|
||||
/// <param name="scope">The scope on which to acquire the write locks.</param>
|
||||
/// <param name="lockIds">The collection of lock IDs to acquire write locks for.</param>
|
||||
public static void WriteLock(this IScope scope, ICollection<int> lockIds)
|
||||
{
|
||||
foreach (var lockId in lockIds)
|
||||
|
||||
@@ -5,12 +5,16 @@ using Umbraco.Cms.Infrastructure.BackgroundJobs;
|
||||
|
||||
namespace Umbraco.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Contains extension methods for <see cref="IServiceCollection"/> to configure and register Umbraco-related services.
|
||||
/// </summary>
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds a recurring background job with an implementation type of
|
||||
/// <typeparamref name="TJob" /> to the specified <see cref="IServiceCollection" />.
|
||||
/// </summary>
|
||||
/// <param name="services">The <see cref="IServiceCollection" /> to add the recurring background job to.</param>
|
||||
public static void AddRecurringBackgroundJob<TJob>(
|
||||
this IServiceCollection services)
|
||||
where TJob : class, IRecurringBackgroundJob =>
|
||||
@@ -21,6 +25,8 @@ public static class ServiceCollectionExtensions
|
||||
/// <typeparamref name="TJob" /> using the factory <paramref name="implementationFactory"/>
|
||||
/// to the specified <see cref="IServiceCollection" />.
|
||||
/// </summary>
|
||||
/// <param name="services">The <see cref="IServiceCollection" /> to add the recurring background job to.</param>
|
||||
/// <param name="implementationFactory">A factory function to create an instance of <typeparamref name="TJob" /> using the provided <see cref="IServiceProvider" />.</param>
|
||||
public static void AddRecurringBackgroundJob<TJob>(
|
||||
this IServiceCollection services,
|
||||
Func<IServiceProvider, TJob> implementationFactory)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.Factories;
|
||||
using Umbraco.Cms.Core.Mapping;
|
||||
@@ -8,12 +8,22 @@ using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Factories.Installer;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a factory for creating and configuring database settings used during the installation process.
|
||||
/// </summary>
|
||||
public class DatabaseSettingsFactory : IDatabaseSettingsFactory
|
||||
{
|
||||
private readonly IEnumerable<IDatabaseProviderMetadata> _databaseProviderMetadata;
|
||||
private readonly IOptionsMonitor<ConnectionStrings> _connectionStrings;
|
||||
private readonly IUmbracoMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Cms.Infrastructure.Factories.Installer.DatabaseSettingsFactory"/> class,
|
||||
/// used to create and configure database settings during the installation process.
|
||||
/// </summary>
|
||||
/// <param name="databaseProviderMetadata">A collection containing metadata for available database providers.</param>
|
||||
/// <param name="connectionStrings">An <see cref="IOptionsMonitor{TOptions}"/> instance for monitoring <see cref="ConnectionStrings"/> options.</param>
|
||||
/// <param name="mapper">The <see cref="IUmbracoMapper"/> instance used for mapping objects within Umbraco.</param>
|
||||
public DatabaseSettingsFactory(
|
||||
IEnumerable<IDatabaseProviderMetadata> databaseProviderMetadata,
|
||||
IOptionsMonitor<ConnectionStrings> connectionStrings,
|
||||
|
||||
@@ -5,18 +5,37 @@ using Umbraco.Cms.Core.HealthChecks.NotificationMethods;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.HealthChecks;
|
||||
|
||||
/// <summary>
|
||||
/// Provides functionality to convert Markdown-formatted text into HTML.
|
||||
/// </summary>
|
||||
public class MarkdownToHtmlConverter : IMarkdownToHtmlConverter
|
||||
{
|
||||
private readonly Core.Strings.IMarkdownToHtmlConverter _markdownToHtmlConverter;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MarkdownToHtmlConverter"/> class,
|
||||
/// using the specified markdown to HTML converter implementation.
|
||||
/// </summary>
|
||||
/// <param name="markdownToHtmlConverter">An implementation of <see cref="Core.Strings.IMarkdownToHtmlConverter"/> used to convert markdown content to HTML.</param>
|
||||
public MarkdownToHtmlConverter(Core.Strings.IMarkdownToHtmlConverter markdownToHtmlConverter) => _markdownToHtmlConverter = markdownToHtmlConverter;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MarkdownToHtmlConverter"/> class.
|
||||
/// This is the parameterless constructor.
|
||||
/// </summary>
|
||||
[Obsolete("Please use the constructor taking all parameters. Scheduled for removal in Umbraco 19.")]
|
||||
public MarkdownToHtmlConverter()
|
||||
: this(StaticServiceProvider.Instance.GetRequiredService<Core.Strings.IMarkdownToHtmlConverter>())
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the specified health check results to an HTML string by first generating a Markdown representation
|
||||
/// of the results (according to the given verbosity), converting that Markdown to HTML, and then applying additional HTML highlighting.
|
||||
/// </summary>
|
||||
/// <param name="results">The <see cref="HealthCheckResults"/> to convert to HTML.</param>
|
||||
/// <param name="verbosity">The verbosity level that determines the detail included in the Markdown representation.</param>
|
||||
/// <returns>An HTML string representing the health check results, with highlighting applied.</returns>
|
||||
public string ToHtml(HealthCheckResults results, HealthCheckNotificationVerbosity verbosity)
|
||||
{
|
||||
var html = _markdownToHtmlConverter.ToHtml(results.ResultsAsMarkDown(verbosity));
|
||||
|
||||
@@ -14,6 +14,11 @@ public class QueuedHostedService : BackgroundService
|
||||
{
|
||||
private readonly ILogger<QueuedHostedService> _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="QueuedHostedService"/> class.
|
||||
/// </summary>
|
||||
/// <param name="taskQueue">The queue that provides background tasks to be processed.</param>
|
||||
/// <param name="logger">The logger used for logging information and errors related to the hosted service.</param>
|
||||
public QueuedHostedService(
|
||||
IBackgroundTaskQueue taskQueue,
|
||||
ILogger<QueuedHostedService> logger)
|
||||
@@ -22,8 +27,16 @@ public class QueuedHostedService : BackgroundService
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the queue that manages background tasks for this hosted service.
|
||||
/// </summary>
|
||||
public IBackgroundTaskQueue TaskQueue { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initiates a graceful shutdown of the hosted service.
|
||||
/// </summary>
|
||||
/// <param name="stoppingToken">A <see cref="CancellationToken"/> that is triggered when the host is performing a graceful shutdown.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous stop operation.</returns>
|
||||
public override async Task StopAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
_logger.LogInformation("Queued Hosted Service is stopping.");
|
||||
|
||||
@@ -155,6 +155,11 @@ public abstract class RecurringHostedServiceBase : IHostedService, IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the core logic of the recurring hosted service asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="state">An optional object containing state information for the execution.</param>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous execution of the recurring task.</returns>
|
||||
public abstract Task PerformExecuteAsync(object? state);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -8,36 +8,108 @@ namespace Umbraco.Cms.Core;
|
||||
/// </summary>
|
||||
public interface IPublishedContentQuery
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves the published content item corresponding to the specified identifier.
|
||||
/// </summary>
|
||||
/// <param name="id">The unique identifier of the content item to retrieve.</param>
|
||||
/// <returns>The <see cref="IPublishedContent"/> instance if found; otherwise, <c>null</c>.</returns>
|
||||
IPublishedContent? Content(int id);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the published content item with the specified unique identifier.
|
||||
/// </summary>
|
||||
/// <param name="id">The unique <see cref="Guid"/> identifier of the content item.</param>
|
||||
/// <returns>The <see cref="IPublishedContent"/> instance if found; otherwise, <c>null</c>.</returns>
|
||||
IPublishedContent? Content(Guid id);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the published content item with the specified unique document identifier (UDI).
|
||||
/// </summary>
|
||||
/// <param name="id">The unique document identifier (UDI) of the content item to retrieve.</param>
|
||||
/// <returns>The <see cref="IPublishedContent"/> instance if found; otherwise, <c>null</c>.</returns>
|
||||
IPublishedContent? Content(Udi id);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the published content item with the specified identifier.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the content item to retrieve.</param>
|
||||
/// <returns>The published content item if found; otherwise, null.</returns>
|
||||
IPublishedContent? Content(object id);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the published content items corresponding to the specified collection of content IDs.
|
||||
/// </summary>
|
||||
/// <param name="ids">A collection of content item IDs to look up.</param>
|
||||
/// <returns>An enumerable of <see cref="IPublishedContent"/> instances matching the provided IDs. Items not found are omitted.</returns>
|
||||
IEnumerable<IPublishedContent> Content(IEnumerable<int> ids);
|
||||
|
||||
/// <summary>Gets the published content items for the specified unique identifiers.</summary>
|
||||
/// <param name="ids">The unique identifiers of the content items to retrieve.</param>
|
||||
/// <returns>An enumerable collection of published content items matching the specified identifiers.</returns>
|
||||
IEnumerable<IPublishedContent> Content(IEnumerable<Guid> ids);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the published content items corresponding to the specified IDs.
|
||||
/// </summary>
|
||||
/// <param name="ids">A collection of IDs identifying the content items to retrieve.</param>
|
||||
/// <returns>An enumerable collection of <see cref="IPublishedContent"/> items matching the provided IDs.</returns>
|
||||
IEnumerable<IPublishedContent> Content(IEnumerable<object> ids);
|
||||
|
||||
/// <summary>Gets the published content items at the root level of the content tree.</summary>
|
||||
/// <returns>An enumerable collection of root-level <see cref="Umbraco.Cms.Core.Models.IPublishedContent"/> items.</returns>
|
||||
IEnumerable<IPublishedContent> ContentAtRoot();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the media item with the specified identifier.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the media item.</param>
|
||||
/// <returns>The media item if found; otherwise, null.</returns>
|
||||
IPublishedContent? Media(int id);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the media item with the specified unique identifier.
|
||||
/// </summary>
|
||||
/// <param name="id">The unique <see cref="Guid"/> identifier of the media item.</param>
|
||||
/// <returns>The <see cref="IPublishedContent"/> representing the media item if found; otherwise, <c>null</c>.</returns>
|
||||
IPublishedContent? Media(Guid id);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a media item using its unique identifier (UDI).
|
||||
/// </summary>
|
||||
/// <param name="id">The unique identifier (UDI) of the media item.</param>
|
||||
/// <returns>The <see cref="IPublishedContent"/> representing the media item if found; otherwise, <c>null</c>.</returns>
|
||||
IPublishedContent? Media(Udi id);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the media item corresponding to the specified identifier.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the media item to retrieve.</param>
|
||||
/// <returns>The <see cref="IPublishedContent"/> representing the media item if found; otherwise, <c>null</c>.</returns>
|
||||
IPublishedContent? Media(object id);
|
||||
|
||||
/// <summary>Gets the media items corresponding to the specified IDs.</summary>
|
||||
/// <param name="ids">The collection of media item IDs to retrieve.</param>
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="Umbraco.Cms.Core.Models.IPublishedContent"/> representing the found media items.</returns>
|
||||
IEnumerable<IPublishedContent> Media(IEnumerable<int> ids);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves media items corresponding to the specified identifiers.
|
||||
/// </summary>
|
||||
/// <param name="ids">A collection of identifiers for the media items to retrieve.</param>
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="Umbraco.Cms.Core.Models.IPublishedContent"/> representing the found media items.</returns>
|
||||
IEnumerable<IPublishedContent> Media(IEnumerable<object> ids);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves media items corresponding to the specified unique identifiers.
|
||||
/// </summary>
|
||||
/// <param name="ids">A collection of unique identifiers for the media items to retrieve.</param>
|
||||
/// <returns>An enumerable collection of media items matching the provided identifiers.</returns>
|
||||
IEnumerable<IPublishedContent> Media(IEnumerable<Guid> ids);
|
||||
|
||||
/// <summary>
|
||||
/// Returns all media items that are located at the root of the media library.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="IEnumerable{IPublishedContent}"/> containing the root-level media items.</returns>
|
||||
IEnumerable<IPublishedContent> MediaAtRoot();
|
||||
|
||||
/// <summary>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user