refactor(core): add IContentPublishOperationService injection to ContentService

Adds field, property, and constructor parameter for the new
publish operation service. Obsolete constructors use lazy
resolution for backward compatibility.

Part of ContentService refactoring Phase 5.
This commit is contained in:
2025-12-23 19:58:11 +00:00
parent 392ab5ec87
commit ea4602ec15

View File

@@ -63,6 +63,10 @@ public class ContentService : RepositoryService, IContentService
private readonly IContentMoveOperationService? _moveOperationService; private readonly IContentMoveOperationService? _moveOperationService;
private readonly Lazy<IContentMoveOperationService>? _moveOperationServiceLazy; private readonly Lazy<IContentMoveOperationService>? _moveOperationServiceLazy;
// Publish operation service fields (for Phase 5 extracted publish operations)
private readonly IContentPublishOperationService? _publishOperationService;
private readonly Lazy<IContentPublishOperationService>? _publishOperationServiceLazy;
/// <summary> /// <summary>
/// Gets the query operation service. /// Gets the query operation service.
/// </summary> /// </summary>
@@ -87,6 +91,14 @@ public class ContentService : RepositoryService, IContentService
_moveOperationService ?? _moveOperationServiceLazy?.Value _moveOperationService ?? _moveOperationServiceLazy?.Value
?? throw new InvalidOperationException("MoveOperationService not initialized. Ensure the service is properly injected via constructor."); ?? throw new InvalidOperationException("MoveOperationService not initialized. Ensure the service is properly injected via constructor.");
/// <summary>
/// Gets the publish operation service.
/// </summary>
/// <exception cref="InvalidOperationException">Thrown if the service was not properly initialized.</exception>
private IContentPublishOperationService PublishOperationService =>
_publishOperationService ?? _publishOperationServiceLazy?.Value
?? throw new InvalidOperationException("PublishOperationService not initialized. Ensure the service is properly injected via constructor.");
#region Constructors #region Constructors
[Microsoft.Extensions.DependencyInjection.ActivatorUtilitiesConstructor] [Microsoft.Extensions.DependencyInjection.ActivatorUtilitiesConstructor]
@@ -111,7 +123,8 @@ public class ContentService : RepositoryService, IContentService
IContentCrudService crudService, IContentCrudService crudService,
IContentQueryOperationService queryOperationService, // NEW PARAMETER - Phase 2 query operations IContentQueryOperationService queryOperationService, // NEW PARAMETER - Phase 2 query operations
IContentVersionOperationService versionOperationService, // NEW PARAMETER - Phase 3 version operations IContentVersionOperationService versionOperationService, // NEW PARAMETER - Phase 3 version operations
IContentMoveOperationService moveOperationService) // NEW PARAMETER - Phase 4 move operations IContentMoveOperationService moveOperationService, // NEW PARAMETER - Phase 4 move operations
IContentPublishOperationService publishOperationService) // NEW PARAMETER - Phase 5 publish operations
: base(provider, loggerFactory, eventMessagesFactory) : base(provider, loggerFactory, eventMessagesFactory)
{ {
_documentRepository = documentRepository; _documentRepository = documentRepository;
@@ -151,6 +164,11 @@ public class ContentService : RepositoryService, IContentService
ArgumentNullException.ThrowIfNull(moveOperationService); ArgumentNullException.ThrowIfNull(moveOperationService);
_moveOperationService = moveOperationService; _moveOperationService = moveOperationService;
_moveOperationServiceLazy = null; // Not needed when directly injected _moveOperationServiceLazy = null; // Not needed when directly injected
// Phase 5: Publish operation service (direct injection)
ArgumentNullException.ThrowIfNull(publishOperationService);
_publishOperationService = publishOperationService;
_publishOperationServiceLazy = null; // Not needed when directly injected
} }
[Obsolete("Use the non-obsolete constructor instead. Scheduled removal in v19.")] [Obsolete("Use the non-obsolete constructor instead. Scheduled removal in v19.")]
@@ -217,6 +235,11 @@ public class ContentService : RepositoryService, IContentService
_moveOperationServiceLazy = new Lazy<IContentMoveOperationService>(() => _moveOperationServiceLazy = new Lazy<IContentMoveOperationService>(() =>
StaticServiceProvider.Instance.GetRequiredService<IContentMoveOperationService>(), StaticServiceProvider.Instance.GetRequiredService<IContentMoveOperationService>(),
LazyThreadSafetyMode.ExecutionAndPublication); LazyThreadSafetyMode.ExecutionAndPublication);
// Phase 5: Lazy resolution of IContentPublishOperationService
_publishOperationServiceLazy = new Lazy<IContentPublishOperationService>(() =>
StaticServiceProvider.Instance.GetRequiredService<IContentPublishOperationService>(),
LazyThreadSafetyMode.ExecutionAndPublication);
} }
[Obsolete("Use the non-obsolete constructor instead. Scheduled removal in v19.")] [Obsolete("Use the non-obsolete constructor instead. Scheduled removal in v19.")]
@@ -282,6 +305,11 @@ public class ContentService : RepositoryService, IContentService
_moveOperationServiceLazy = new Lazy<IContentMoveOperationService>(() => _moveOperationServiceLazy = new Lazy<IContentMoveOperationService>(() =>
StaticServiceProvider.Instance.GetRequiredService<IContentMoveOperationService>(), StaticServiceProvider.Instance.GetRequiredService<IContentMoveOperationService>(),
LazyThreadSafetyMode.ExecutionAndPublication); LazyThreadSafetyMode.ExecutionAndPublication);
// Phase 5: Lazy resolution of IContentPublishOperationService
_publishOperationServiceLazy = new Lazy<IContentPublishOperationService>(() =>
StaticServiceProvider.Instance.GetRequiredService<IContentPublishOperationService>(),
LazyThreadSafetyMode.ExecutionAndPublication);
} }
#endregion #endregion