Class FileServiceOperationBase<TRepository, TEntity, TOperationStatus>
Provides base functionality for file services that support CRUD operations with notifications and auditing.
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public abstract class FileServiceOperationBase<TRepository, TEntity, TOperationStatus> : FileServiceBase<TRepository, TEntity>, IService, IBasicFileService<TEntity> where TRepository : IFileRepository, IReadRepository<string, TEntity>, IWriteRepository<TEntity>, IFileWithFoldersRepository where TEntity : IFile where TOperationStatus : Enum
Type Parameters
| Name | Description |
|---|---|
| TRepository | The type of repository used for file operations, supporting read, write, and folder operations. |
| TEntity | The type of file entity being managed. |
| TOperationStatus | The enum type representing operation status codes. |
Remarks
This abstract class extends FileServiceBase<TRepository, TEntity> to add support for create, update, rename, and delete operations with proper notification publishing and audit logging.
Constructors
View SourceFileServiceOperationBase(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, TRepository, ILogger<StylesheetService>, IUserIdKeyResolver, IAuditRepository)
Initializes a new instance of the FileServiceOperationBase<TRepository, TEntity, TOperationStatus> class.
Declaration
[Obsolete("Use the non-obsolete constructor instead. Scheduled for removal in Umbraco 19.")]
protected FileServiceOperationBase(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, TRepository repository, ILogger<StylesheetService> logger, IUserIdKeyResolver userIdKeyResolver, IAuditRepository auditRepository)
Parameters
| Type | Name | Description |
|---|---|---|
| ICoreScopeProvider | provider | The core scope provider. |
| ILoggerFactory | loggerFactory | The logger factory. |
| IEventMessagesFactory | eventMessagesFactory | The event messages factory. |
| TRepository | repository | The file repository. |
| ILogger<StylesheetService> | logger | The logger. |
| IUserIdKeyResolver | userIdKeyResolver | The user ID key resolver. |
| IAuditRepository | auditRepository | The audit repository. |
FileServiceOperationBase(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, TRepository, ILogger<StylesheetService>, IUserIdKeyResolver, IAuditService)
Initializes a new instance of the FileServiceOperationBase<TRepository, TEntity, TOperationStatus> class.
Declaration
protected FileServiceOperationBase(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, TRepository repository, ILogger<StylesheetService> logger, IUserIdKeyResolver userIdKeyResolver, IAuditService auditService)
Parameters
| Type | Name | Description |
|---|---|---|
| ICoreScopeProvider | provider | The core scope provider for database operations. |
| ILoggerFactory | loggerFactory | The logger factory for creating loggers. |
| IEventMessagesFactory | eventMessagesFactory | The factory for creating event messages. |
| TRepository | repository | The repository for file data access. |
| ILogger<StylesheetService> | logger | The logger for operation logging. |
| IUserIdKeyResolver | userIdKeyResolver | The resolver for converting user IDs to keys. |
| IAuditService | auditService | The audit service for logging operations. |
Properties
View SourceAlreadyExists
Gets the operation status value representing an entity that already exists.
Declaration
protected abstract TOperationStatus AlreadyExists { get; }
Property Value
| Type | Description |
|---|---|
| TOperationStatus |
CancelledByNotification
Gets the operation status value representing a cancellation by notification handler.
Declaration
protected abstract TOperationStatus CancelledByNotification { get; }
Property Value
| Type | Description |
|---|---|
| TOperationStatus |
EntityType
Gets the entity type name used for audit logging.
Declaration
protected abstract string EntityType { get; }
Property Value
| Type | Description |
|---|---|
| string |
InvalidFileExtension
Gets the operation status value representing an invalid file extension.
Declaration
protected abstract TOperationStatus InvalidFileExtension { get; }
Property Value
| Type | Description |
|---|---|
| TOperationStatus |
InvalidName
Gets the operation status value representing an invalid file name.
Declaration
protected abstract TOperationStatus InvalidName { get; }
Property Value
| Type | Description |
|---|---|
| TOperationStatus |
NotFound
Gets the operation status value representing an entity not found condition.
Declaration
protected abstract TOperationStatus NotFound { get; }
Property Value
| Type | Description |
|---|---|
| TOperationStatus |
ParentNotFound
Gets the operation status value representing a parent folder not found condition.
Declaration
protected abstract TOperationStatus ParentNotFound { get; }
Property Value
| Type | Description |
|---|---|
| TOperationStatus |
PathTooLong
Gets the operation status value representing a path that exceeds maximum length.
Declaration
protected abstract TOperationStatus PathTooLong { get; }
Property Value
| Type | Description |
|---|---|
| TOperationStatus |
Success
Gets the operation status value representing a successful operation.
Declaration
protected abstract TOperationStatus Success { get; }
Property Value
| Type | Description |
|---|---|
| TOperationStatus |
Methods
View SourceCreateEntity(string, string?)
Creates a new entity instance with the specified path and content.
Declaration
protected abstract TEntity CreateEntity(string path, string? content)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The file path for the entity. |
| string | content | The optional content of the file. |
Returns
| Type | Description |
|---|---|
| TEntity | A new entity instance. |
DeletedNotification(TEntity, EventMessages)
Creates a deleted notification for the specified entity.
Declaration
protected abstract DeletedNotification<TEntity> DeletedNotification(TEntity target, EventMessages messages)
Parameters
| Type | Name | Description |
|---|---|---|
| TEntity | target | The entity that was deleted. |
| EventMessages | messages | The event messages to include. |
Returns
| Type | Description |
|---|---|
| DeletedNotification<TEntity> | A deleted notification instance. |
DeletingNotification(TEntity, EventMessages)
Creates a deleting notification for the specified entity.
Declaration
protected abstract DeletingNotification<TEntity> DeletingNotification(TEntity target, EventMessages messages)
Parameters
| Type | Name | Description |
|---|---|---|
| TEntity | target | The entity being deleted. |
| EventMessages | messages | The event messages to include. |
Returns
| Type | Description |
|---|---|
| DeletingNotification<TEntity> | A deleting notification instance. |
HandleCreateAsync(string, string?, string?, Guid)
Handles the creation of a new file entity.
Declaration
protected Task<Attempt<TEntity?, TOperationStatus>> HandleCreateAsync(string name, string? parentPath, string? content, Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the file to create. |
| string | parentPath | The optional parent folder path. |
| string | content | The optional initial content of the file. |
| Guid | userKey | The unique identifier of the user performing the operation. |
Returns
| Type | Description |
|---|---|
| Task<Attempt<TEntity, TOperationStatus>> | An attempt containing the created entity and operation status. |
HandleDeleteAsync(string, Guid)
Handles the deletion of a file entity.
Declaration
protected Task<TOperationStatus> HandleDeleteAsync(string path, Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The path of the file to delete. |
| Guid | userKey | The unique identifier of the user performing the operation. |
Returns
| Type | Description |
|---|---|
| Task<TOperationStatus> | The operation status indicating success or failure reason. |
HandleRenameAsync(string, string, Guid)
Handles the renaming of an existing file entity.
Declaration
protected Task<Attempt<TEntity?, TOperationStatus>> HandleRenameAsync(string path, string newName, Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The current path of the file. |
| string | newName | The new name for the file. |
| Guid | userKey | The unique identifier of the user performing the operation. |
Returns
| Type | Description |
|---|---|
| Task<Attempt<TEntity, TOperationStatus>> | An attempt containing the renamed entity and operation status. |
HandleUpdateAsync(string, string, Guid)
Handles the update of an existing file entity's content.
Declaration
protected Task<Attempt<TEntity?, TOperationStatus>> HandleUpdateAsync(string path, string content, Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The path of the file to update. |
| string | content | The new content for the file. |
| Guid | userKey | The unique identifier of the user performing the operation. |
Returns
| Type | Description |
|---|---|
| Task<Attempt<TEntity, TOperationStatus>> | An attempt containing the updated entity and operation status. |
SavedNotification(TEntity, EventMessages)
Creates a saved notification for the specified entity.
Declaration
protected abstract SavedNotification<TEntity> SavedNotification(TEntity target, EventMessages messages)
Parameters
| Type | Name | Description |
|---|---|---|
| TEntity | target | The entity that was saved. |
| EventMessages | messages | The event messages to include. |
Returns
| Type | Description |
|---|---|
| SavedNotification<TEntity> | A saved notification instance. |
SavingNotification(TEntity, EventMessages)
Creates a saving notification for the specified entity.
Declaration
protected abstract SavingNotification<TEntity> SavingNotification(TEntity target, EventMessages messages)
Parameters
| Type | Name | Description |
|---|---|---|
| TEntity | target | The entity being saved. |
| EventMessages | messages | The event messages to include. |
Returns
| Type | Description |
|---|---|
| SavingNotification<TEntity> | A saving notification instance. |