Merge remote-tracking branch 'origin/v14/dev' into v14/dev
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.1" />
|
||||
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
|
||||
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Umbraco.Cms.Api.Management.ViewModels.Content;
|
||||
using Umbraco.Cms.Api.Management.ViewModels.Document;
|
||||
using Umbraco.Cms.Core.Models.ContentEditing;
|
||||
using Umbraco.Cms.Core.Models.ContentEditing.Validation;
|
||||
using Umbraco.Cms.Core.Models.ContentPublishing;
|
||||
using Umbraco.Cms.Core.Services.OperationStatus;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
@@ -63,7 +61,8 @@ public class ContentControllerBase : ManagementApiControllerBase
|
||||
.WithTitle("Invalid sorting options")
|
||||
.WithDetail("The supplied sorting operations were invalid. Additional details can be found in the log.")
|
||||
.Build()),
|
||||
ContentEditingOperationStatus.Unknown => StatusCode(StatusCodes.Status500InternalServerError,
|
||||
ContentEditingOperationStatus.Unknown => StatusCode(
|
||||
StatusCodes.Status500InternalServerError,
|
||||
problemDetailsBuilder
|
||||
.WithTitle("Unknown error. Please see the log for more details.")
|
||||
.Build()),
|
||||
@@ -112,125 +111,4 @@ public class ContentControllerBase : ManagementApiControllerBase
|
||||
.WithExtension("missingProperties", missingPropertyAliases.ToArray())
|
||||
.Build()));
|
||||
}
|
||||
|
||||
protected IActionResult ContentPublishingOperationStatusResult(
|
||||
ContentPublishingOperationStatus status,
|
||||
IEnumerable<string>? invalidPropertyAliases = null,
|
||||
IEnumerable<ContentPublishingBranchItemResult>? failedBranchItems = null)
|
||||
=> OperationStatusResult(status, problemDetailsBuilder => status switch
|
||||
{
|
||||
ContentPublishingOperationStatus.ContentNotFound => NotFound(problemDetailsBuilder
|
||||
.WithTitle("The requested content could not be found")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.CancelledByEvent => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Publish cancelled by event")
|
||||
.WithDetail("The publish operation was cancelled by an event.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.ContentInvalid => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Invalid content")
|
||||
.WithDetail("The specified content had an invalid configuration.")
|
||||
.WithExtension("invalidProperties", invalidPropertyAliases ?? Enumerable.Empty<string>())
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.NothingToPublish => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Nothing to publish")
|
||||
.WithDetail("None of the specified cultures needed publishing.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.MandatoryCultureMissing => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Mandatory culture missing")
|
||||
.WithDetail("Must include all mandatory cultures when publishing.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.HasExpired => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Content expired")
|
||||
.WithDetail("Could not publish the content because it was expired.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.CultureHasExpired => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Content culture expired")
|
||||
.WithDetail("Could not publish the content because some of the specified cultures were expired.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.AwaitingRelease => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Content awaiting release")
|
||||
.WithDetail("Could not publish the content because it was awaiting release.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.CultureAwaitingRelease => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Content culture awaiting release")
|
||||
.WithDetail(
|
||||
"Could not publish the content because some of the specified cultures were awaiting release.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.InTrash => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Content in the recycle bin")
|
||||
.WithDetail("Could not publish the content because it was in the recycle bin.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.PathNotPublished => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Parent not published")
|
||||
.WithDetail("Could not publish the content because its parent was not published.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.ConcurrencyViolation => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Concurrency violation detected")
|
||||
.WithDetail("An attempt was made to publish a version older than the latest version.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.UnsavedChanges => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Unsaved changes")
|
||||
.WithDetail(
|
||||
"Could not publish the content because it had unsaved changes. Make sure to save all changes before attempting a publish.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.FailedBranch => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Failed branch operation")
|
||||
.WithDetail("One or more items in the branch could not complete the operation.")
|
||||
.WithExtension("failedBranchItems", failedBranchItems?.Select(item => new DocumentPublishBranchItemResult
|
||||
{
|
||||
Id = item.Key,
|
||||
OperationStatus = item.OperationStatus
|
||||
}) ?? Enumerable.Empty<DocumentPublishBranchItemResult>())
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.Failed => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Publish or unpublish failed")
|
||||
.WithDetail(
|
||||
"An unspecified error occurred while (un)publishing. Please check the logs for additional information.")
|
||||
.Build()),
|
||||
_ => StatusCode(StatusCodes.Status500InternalServerError, "Unknown content operation status."),
|
||||
});
|
||||
|
||||
protected IActionResult ContentCreatingOperationStatusResult(ContentCreatingOperationStatus status)
|
||||
=> OperationStatusResult(status, problemDetailsBuilder => status switch
|
||||
{
|
||||
ContentCreatingOperationStatus.NotFound => NotFound(problemDetailsBuilder
|
||||
.WithTitle("The content type could not be found")
|
||||
.Build()),
|
||||
_ => StatusCode(StatusCodes.Status500InternalServerError, problemDetailsBuilder
|
||||
.WithTitle("Unknown content operation status.")
|
||||
.Build()),
|
||||
});
|
||||
|
||||
protected IActionResult PublicAccessOperationStatusResult(PublicAccessOperationStatus status)
|
||||
=> OperationStatusResult(status, problemDetailsBuilder => status switch
|
||||
{
|
||||
PublicAccessOperationStatus.ContentNotFound => NotFound(problemDetailsBuilder
|
||||
.WithTitle("The content could not be found")
|
||||
.Build()),
|
||||
PublicAccessOperationStatus.ErrorNodeNotFound => NotFound(problemDetailsBuilder
|
||||
.WithTitle("The error page could not be found")
|
||||
.Build()),
|
||||
PublicAccessOperationStatus.LoginNodeNotFound => NotFound(problemDetailsBuilder
|
||||
.WithTitle("The login page could not be found")
|
||||
.Build()),
|
||||
PublicAccessOperationStatus.NoAllowedEntities => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("No allowed entities given")
|
||||
.WithDetail("Both MemberGroups and Members were empty, thus no entities can be allowed.")
|
||||
.Build()),
|
||||
PublicAccessOperationStatus.CancelledByNotification => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Request cancelled by notification")
|
||||
.WithDetail("The request to save a public access entry was cancelled by a notification handler.")
|
||||
.Build()),
|
||||
PublicAccessOperationStatus.AmbiguousRule => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Ambiguous Rule")
|
||||
.WithDetail("The specified rule is ambiguous, because both member groups and member names were given.")
|
||||
.Build()),
|
||||
PublicAccessOperationStatus.EntryNotFound => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Entry not found")
|
||||
.WithDetail("The specified entry was not found.")
|
||||
.Build()),
|
||||
_ => StatusCode(StatusCodes.Status500InternalServerError, problemDetailsBuilder
|
||||
.WithTitle("Unknown content operation status.")
|
||||
.Build()),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Umbraco.Cms.Api.Management.Controllers.Content;
|
||||
using Umbraco.Cms.Api.Management.Routing;
|
||||
@@ -6,6 +7,7 @@ using Umbraco.Cms.Api.Management.ViewModels.Content;
|
||||
using Umbraco.Cms.Api.Management.ViewModels.Document;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Models.ContentEditing;
|
||||
using Umbraco.Cms.Core.Models.ContentPublishing;
|
||||
using Umbraco.Cms.Core.Services.OperationStatus;
|
||||
using Umbraco.Cms.Web.Common.Authorization;
|
||||
|
||||
@@ -20,7 +22,7 @@ public abstract class DocumentControllerBase : ContentControllerBase
|
||||
protected IActionResult DocumentNotFound()
|
||||
=> OperationStatusResult(ContentEditingOperationStatus.NotFound, problemDetailsBuilder
|
||||
=> NotFound(problemDetailsBuilder
|
||||
.WithTitle("The requested Document could not be found")
|
||||
.WithTitle("The document could not be found")
|
||||
.Build()));
|
||||
|
||||
protected IActionResult DocumentEditingOperationStatusResult<TContentModelBase>(
|
||||
@@ -29,4 +31,114 @@ public abstract class DocumentControllerBase : ContentControllerBase
|
||||
ContentValidationResult validationResult)
|
||||
where TContentModelBase : ContentModelBase<DocumentValueModel, DocumentVariantRequestModel>
|
||||
=> ContentEditingOperationStatusResult<TContentModelBase, DocumentValueModel, DocumentVariantRequestModel>(status, requestModel, validationResult);
|
||||
|
||||
protected IActionResult DocumentPublishingOperationStatusResult(
|
||||
ContentPublishingOperationStatus status,
|
||||
IEnumerable<string>? invalidPropertyAliases = null,
|
||||
IEnumerable<ContentPublishingBranchItemResult>? failedBranchItems = null)
|
||||
=> OperationStatusResult(status, problemDetailsBuilder => status switch
|
||||
{
|
||||
ContentPublishingOperationStatus.ContentNotFound => NotFound(problemDetailsBuilder
|
||||
.WithTitle("The requested document could not be found")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.CancelledByEvent => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Publish cancelled by event")
|
||||
.WithDetail("The publish operation was cancelled by an event.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.ContentInvalid => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Invalid document")
|
||||
.WithDetail("The specified document had an invalid configuration.")
|
||||
.WithExtension("invalidProperties", invalidPropertyAliases ?? Enumerable.Empty<string>())
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.NothingToPublish => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Nothing to publish")
|
||||
.WithDetail("None of the specified cultures needed publishing.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.MandatoryCultureMissing => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Mandatory culture missing")
|
||||
.WithDetail("Must include all mandatory cultures when publishing.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.HasExpired => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Document expired")
|
||||
.WithDetail("Could not publish the document because it was expired.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.CultureHasExpired => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Document culture expired")
|
||||
.WithDetail("Could not publish the document because some of the specified cultures were expired.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.AwaitingRelease => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Document awaiting release")
|
||||
.WithDetail("Could not publish the document because it was awaiting release.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.CultureAwaitingRelease => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Document culture awaiting release")
|
||||
.WithDetail(
|
||||
"Could not publish the document because some of the specified cultures were awaiting release.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.InTrash => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Document in the recycle bin")
|
||||
.WithDetail("Could not publish the document because it was in the recycle bin.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.PathNotPublished => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Parent not published")
|
||||
.WithDetail("Could not publish the document because its parent was not published.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.ConcurrencyViolation => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Concurrency violation detected")
|
||||
.WithDetail("An attempt was made to publish a version older than the latest version.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.UnsavedChanges => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Unsaved changes")
|
||||
.WithDetail(
|
||||
"Could not publish the document because it had unsaved changes. Make sure to save all changes before attempting a publish.")
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.FailedBranch => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Failed branch operation")
|
||||
.WithDetail("One or more items in the branch could not complete the operation.")
|
||||
.WithExtension("failedBranchItems", failedBranchItems?.Select(item => new DocumentPublishBranchItemResult
|
||||
{
|
||||
Id = item.Key,
|
||||
OperationStatus = item.OperationStatus
|
||||
}) ?? Enumerable.Empty<DocumentPublishBranchItemResult>())
|
||||
.Build()),
|
||||
ContentPublishingOperationStatus.Failed => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Publish or unpublish failed")
|
||||
.WithDetail(
|
||||
"An unspecified error occurred while (un)publishing. Please check the logs for additional information.")
|
||||
.Build()),
|
||||
_ => StatusCode(StatusCodes.Status500InternalServerError, "Unknown content operation status."),
|
||||
});
|
||||
|
||||
protected IActionResult PublicAccessOperationStatusResult(PublicAccessOperationStatus status)
|
||||
=> OperationStatusResult(status, problemDetailsBuilder => status switch
|
||||
{
|
||||
PublicAccessOperationStatus.ContentNotFound => NotFound(problemDetailsBuilder
|
||||
.WithTitle("The document could not be found")
|
||||
.Build()),
|
||||
PublicAccessOperationStatus.ErrorNodeNotFound => NotFound(problemDetailsBuilder
|
||||
.WithTitle("The error page could not be found")
|
||||
.Build()),
|
||||
PublicAccessOperationStatus.LoginNodeNotFound => NotFound(problemDetailsBuilder
|
||||
.WithTitle("The login page could not be found")
|
||||
.Build()),
|
||||
PublicAccessOperationStatus.NoAllowedEntities => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("No allowed entities given")
|
||||
.WithDetail("Both MemberGroups and Members were empty, thus no entities can be allowed.")
|
||||
.Build()),
|
||||
PublicAccessOperationStatus.CancelledByNotification => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Request cancelled by notification")
|
||||
.WithDetail("The request to save a public access entry was cancelled by a notification handler.")
|
||||
.Build()),
|
||||
PublicAccessOperationStatus.AmbiguousRule => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Ambiguous Rule")
|
||||
.WithDetail("The specified rule is ambiguous, because both member groups and member names were given.")
|
||||
.Build()),
|
||||
PublicAccessOperationStatus.EntryNotFound => BadRequest(problemDetailsBuilder
|
||||
.WithTitle("Entry not found")
|
||||
.WithDetail("The specified entry was not found.")
|
||||
.Build()),
|
||||
_ => StatusCode(StatusCodes.Status500InternalServerError, problemDetailsBuilder
|
||||
.WithTitle("Unknown content operation status.")
|
||||
.Build()),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -56,6 +56,6 @@ public class PublishDocumentController : DocumentControllerBase
|
||||
CurrentUserKey(_backOfficeSecurityAccessor));
|
||||
return attempt.Success
|
||||
? Ok()
|
||||
: ContentPublishingOperationStatusResult(attempt.Status, invalidPropertyAliases: attempt.Result.InvalidPropertyAliases);
|
||||
: DocumentPublishingOperationStatusResult(attempt.Status, invalidPropertyAliases: attempt.Result.InvalidPropertyAliases);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,6 @@ public class PublishDocumentWithDescendantsController : DocumentControllerBase
|
||||
|
||||
return attempt.Success
|
||||
? Ok()
|
||||
: ContentPublishingOperationStatusResult(attempt.Status, failedBranchItems: attempt.Result.FailedItems);
|
||||
: DocumentPublishingOperationStatusResult(attempt.Status, failedBranchItems: attempt.Result.FailedItems);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,6 @@ public class UnpublishDocumentController : DocumentControllerBase
|
||||
CurrentUserKey(_backOfficeSecurityAccessor));
|
||||
return attempt.Success
|
||||
? Ok()
|
||||
: ContentPublishingOperationStatusResult(attempt.Result);
|
||||
: DocumentPublishingOperationStatusResult(attempt.Result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,16 +18,16 @@ public class ByKeyMediaController : MediaControllerBase
|
||||
{
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly IMediaEditingService _mediaEditingService;
|
||||
private readonly IMediaPresentationModelFactory _mediaPresentationModelFactory;
|
||||
private readonly IMediaPresentationFactory _mediaPresentationFactory;
|
||||
|
||||
public ByKeyMediaController(
|
||||
IAuthorizationService authorizationService,
|
||||
IMediaEditingService mediaEditingService,
|
||||
IMediaPresentationModelFactory mediaPresentationModelFactory)
|
||||
IMediaPresentationFactory mediaPresentationFactory)
|
||||
{
|
||||
_authorizationService = authorizationService;
|
||||
_mediaEditingService = mediaEditingService;
|
||||
_mediaPresentationModelFactory = mediaPresentationModelFactory;
|
||||
_mediaPresentationFactory = mediaPresentationFactory;
|
||||
}
|
||||
|
||||
[HttpGet("{id:guid}")]
|
||||
@@ -52,7 +52,7 @@ public class ByKeyMediaController : MediaControllerBase
|
||||
return MediaNotFound();
|
||||
}
|
||||
|
||||
MediaResponseModel model = await _mediaPresentationModelFactory.CreateResponseModelAsync(media);
|
||||
MediaResponseModel model = await _mediaPresentationFactory.CreateResponseModelAsync(media);
|
||||
return Ok(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,12 @@ namespace Umbraco.Cms.Api.Management.Controllers.Media.Item;
|
||||
public class ItemMediaItemController : MediaItemControllerBase
|
||||
{
|
||||
private readonly IEntityService _entityService;
|
||||
private readonly IMediaPresentationModelFactory _mediaPresentationModelFactory;
|
||||
private readonly IMediaPresentationFactory _mediaPresentationFactory;
|
||||
|
||||
public ItemMediaItemController(IEntityService entityService, IMediaPresentationModelFactory mediaPresentationModelFactory)
|
||||
public ItemMediaItemController(IEntityService entityService, IMediaPresentationFactory mediaPresentationFactory)
|
||||
{
|
||||
_entityService = entityService;
|
||||
_mediaPresentationModelFactory = mediaPresentationModelFactory;
|
||||
_mediaPresentationFactory = mediaPresentationFactory;
|
||||
}
|
||||
|
||||
[HttpGet("item")]
|
||||
@@ -31,7 +31,7 @@ public class ItemMediaItemController : MediaItemControllerBase
|
||||
.GetAll(UmbracoObjectTypes.Media, ids.ToArray())
|
||||
.OfType<IMediaEntitySlim>();
|
||||
|
||||
IEnumerable<MediaItemResponseModel> responseModels = media.Select(_mediaPresentationModelFactory.CreateItemResponseModel);
|
||||
IEnumerable<MediaItemResponseModel> responseModels = media.Select(_mediaPresentationFactory.CreateItemResponseModel);
|
||||
return await Task.FromResult(Ok(responseModels));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace Umbraco.Cms.Api.Management.Controllers.Media.RecycleBin;
|
||||
[ApiVersion("1.0")]
|
||||
public class ChildrenMediaRecycleBinController : MediaRecycleBinControllerBase
|
||||
{
|
||||
public ChildrenMediaRecycleBinController(IEntityService entityService, IMediaPresentationModelFactory mediaPresentationModelFactory)
|
||||
: base(entityService, mediaPresentationModelFactory)
|
||||
public ChildrenMediaRecycleBinController(IEntityService entityService, IMediaPresentationFactory mediaPresentationFactory)
|
||||
: base(entityService, mediaPresentationFactory)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ public class EmptyMediaRecycleBinController : MediaRecycleBinControllerBase
|
||||
IAuthorizationService authorizationService,
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
|
||||
IMediaService mediaService,
|
||||
IMediaPresentationModelFactory mediaPresentationModelFactory)
|
||||
: base(entityService, mediaPresentationModelFactory)
|
||||
IMediaPresentationFactory mediaPresentationFactory)
|
||||
: base(entityService, mediaPresentationFactory)
|
||||
{
|
||||
_authorizationService = authorizationService;
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
|
||||
@@ -22,11 +22,11 @@ namespace Umbraco.Cms.Api.Management.Controllers.Media.RecycleBin;
|
||||
[Authorize(Policy = "New" + AuthorizationPolicies.SectionAccessMedia)]
|
||||
public class MediaRecycleBinControllerBase : RecycleBinControllerBase<MediaRecycleBinItemResponseModel>
|
||||
{
|
||||
private readonly IMediaPresentationModelFactory _mediaPresentationModelFactory;
|
||||
private readonly IMediaPresentationFactory _mediaPresentationFactory;
|
||||
|
||||
public MediaRecycleBinControllerBase(IEntityService entityService, IMediaPresentationModelFactory mediaPresentationModelFactory)
|
||||
public MediaRecycleBinControllerBase(IEntityService entityService, IMediaPresentationFactory mediaPresentationFactory)
|
||||
: base(entityService)
|
||||
=> _mediaPresentationModelFactory = mediaPresentationModelFactory;
|
||||
=> _mediaPresentationFactory = mediaPresentationFactory;
|
||||
|
||||
protected override UmbracoObjectTypes ItemObjectType => UmbracoObjectTypes.Media;
|
||||
|
||||
@@ -38,8 +38,8 @@ public class MediaRecycleBinControllerBase : RecycleBinControllerBase<MediaRecyc
|
||||
|
||||
if (entity is IMediaEntitySlim mediaEntitySlim)
|
||||
{
|
||||
responseModel.Variants = _mediaPresentationModelFactory.CreateVariantsItemResponseModels(mediaEntitySlim);
|
||||
responseModel.MediaType = _mediaPresentationModelFactory.CreateMediaTypeReferenceResponseModel(mediaEntitySlim);
|
||||
responseModel.Variants = _mediaPresentationFactory.CreateVariantsItemResponseModels(mediaEntitySlim);
|
||||
responseModel.MediaType = _mediaPresentationFactory.CreateMediaTypeReferenceResponseModel(mediaEntitySlim);
|
||||
}
|
||||
|
||||
return responseModel;
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace Umbraco.Cms.Api.Management.Controllers.Media.RecycleBin;
|
||||
[ApiVersion("1.0")]
|
||||
public class RootMediaRecycleBinController : MediaRecycleBinControllerBase
|
||||
{
|
||||
public RootMediaRecycleBinController(IEntityService entityService, IMediaPresentationModelFactory mediaPresentationModelFactory)
|
||||
: base(entityService, mediaPresentationModelFactory)
|
||||
public RootMediaRecycleBinController(IEntityService entityService, IMediaPresentationFactory mediaPresentationFactory)
|
||||
: base(entityService, mediaPresentationFactory)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ public class ChildrenMediaTreeController : MediaTreeControllerBase
|
||||
IDataTypeService dataTypeService,
|
||||
AppCaches appCaches,
|
||||
IBackOfficeSecurityAccessor backofficeSecurityAccessor,
|
||||
IMediaPresentationModelFactory mediaPresentationModelFactory)
|
||||
: base(entityService, userStartNodeEntitiesService, dataTypeService, appCaches, backofficeSecurityAccessor, mediaPresentationModelFactory)
|
||||
IMediaPresentationFactory mediaPresentationFactory)
|
||||
: base(entityService, userStartNodeEntitiesService, dataTypeService, appCaches, backofficeSecurityAccessor, mediaPresentationFactory)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public class MediaTreeControllerBase : UserStartNodeTreeControllerBase<MediaTree
|
||||
{
|
||||
private readonly AppCaches _appCaches;
|
||||
private readonly IBackOfficeSecurityAccessor _backofficeSecurityAccessor;
|
||||
private readonly IMediaPresentationModelFactory _mediaPresentationModelFactory;
|
||||
private readonly IMediaPresentationFactory _mediaPresentationFactory;
|
||||
|
||||
public MediaTreeControllerBase(
|
||||
IEntityService entityService,
|
||||
@@ -31,12 +31,12 @@ public class MediaTreeControllerBase : UserStartNodeTreeControllerBase<MediaTree
|
||||
IDataTypeService dataTypeService,
|
||||
AppCaches appCaches,
|
||||
IBackOfficeSecurityAccessor backofficeSecurityAccessor,
|
||||
IMediaPresentationModelFactory mediaPresentationModelFactory)
|
||||
IMediaPresentationFactory mediaPresentationFactory)
|
||||
: base(entityService, userStartNodeEntitiesService, dataTypeService)
|
||||
{
|
||||
_appCaches = appCaches;
|
||||
_backofficeSecurityAccessor = backofficeSecurityAccessor;
|
||||
_mediaPresentationModelFactory = mediaPresentationModelFactory;
|
||||
_mediaPresentationFactory = mediaPresentationFactory;
|
||||
}
|
||||
|
||||
protected override UmbracoObjectTypes ItemObjectType => UmbracoObjectTypes.Media;
|
||||
@@ -52,8 +52,8 @@ public class MediaTreeControllerBase : UserStartNodeTreeControllerBase<MediaTree
|
||||
responseModel.IsTrashed = entity.Trashed;
|
||||
responseModel.Id = entity.Key;
|
||||
|
||||
responseModel.Variants = _mediaPresentationModelFactory.CreateVariantsItemResponseModels(mediaEntitySlim);
|
||||
responseModel.MediaType = _mediaPresentationModelFactory.CreateMediaTypeReferenceResponseModel(mediaEntitySlim);
|
||||
responseModel.Variants = _mediaPresentationFactory.CreateVariantsItemResponseModels(mediaEntitySlim);
|
||||
responseModel.MediaType = _mediaPresentationFactory.CreateMediaTypeReferenceResponseModel(mediaEntitySlim);
|
||||
}
|
||||
|
||||
return responseModel;
|
||||
|
||||
@@ -20,8 +20,8 @@ public class RootMediaTreeController : MediaTreeControllerBase
|
||||
IDataTypeService dataTypeService,
|
||||
AppCaches appCaches,
|
||||
IBackOfficeSecurityAccessor backofficeSecurityAccessor,
|
||||
IMediaPresentationModelFactory mediaPresentationModelFactory)
|
||||
: base(entityService, userStartNodeEntitiesService, dataTypeService, appCaches, backofficeSecurityAccessor, mediaPresentationModelFactory)
|
||||
IMediaPresentationFactory mediaPresentationFactory)
|
||||
: base(entityService, userStartNodeEntitiesService, dataTypeService, appCaches, backofficeSecurityAccessor, mediaPresentationFactory)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@ namespace Umbraco.Cms.Api.Management.Controllers.PartialView.Item;
|
||||
[ApiVersion("1.0")]
|
||||
public class ItemPartialViewItemController : PartialViewItemControllerBase
|
||||
{
|
||||
private readonly IFileItemPresentationModelFactory _fileItemPresentationModelFactory;
|
||||
private readonly IFileItemPresentationFactory _fileItemPresentationFactory;
|
||||
|
||||
public ItemPartialViewItemController(IFileItemPresentationModelFactory fileItemPresentationModelFactory)
|
||||
=> _fileItemPresentationModelFactory = fileItemPresentationModelFactory;
|
||||
public ItemPartialViewItemController(IFileItemPresentationFactory fileItemPresentationFactory)
|
||||
=> _fileItemPresentationFactory = fileItemPresentationFactory;
|
||||
|
||||
[HttpGet("item")]
|
||||
[MapToApiVersion("1.0")]
|
||||
@@ -21,7 +21,7 @@ public class ItemPartialViewItemController : PartialViewItemControllerBase
|
||||
public async Task<IActionResult> Item([FromQuery(Name = "path")] HashSet<string> paths)
|
||||
{
|
||||
paths = paths.Select(path => path.VirtualPathToSystemPath()).ToHashSet();
|
||||
IEnumerable<PartialViewItemResponseModel> responseModels = _fileItemPresentationModelFactory.CreatePartialViewItemResponseModels(paths);
|
||||
IEnumerable<PartialViewItemResponseModel> responseModels = _fileItemPresentationFactory.CreatePartialViewItemResponseModels(paths);
|
||||
return await Task.FromResult(Ok(responseModels));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ namespace Umbraco.Cms.Api.Management.Controllers.Script.Item;
|
||||
[ApiVersion("1.0")]
|
||||
public class ItemScriptItemController : ScriptItemControllerBase
|
||||
{
|
||||
private readonly IFileItemPresentationModelFactory _fileItemPresentationModelFactory;
|
||||
private readonly IFileItemPresentationFactory _fileItemPresentationFactory;
|
||||
|
||||
public ItemScriptItemController(IFileItemPresentationModelFactory fileItemPresentationModelFactory)
|
||||
=> _fileItemPresentationModelFactory = fileItemPresentationModelFactory;
|
||||
public ItemScriptItemController(IFileItemPresentationFactory fileItemPresentationFactory)
|
||||
=> _fileItemPresentationFactory = fileItemPresentationFactory;
|
||||
|
||||
[HttpGet("item")]
|
||||
[MapToApiVersion("1.0")]
|
||||
@@ -21,7 +21,7 @@ public class ItemScriptItemController : ScriptItemControllerBase
|
||||
public async Task<IActionResult> Item([FromQuery(Name = "path")] HashSet<string> paths)
|
||||
{
|
||||
paths = paths.Select(path => path.VirtualPathToSystemPath()).ToHashSet();
|
||||
IEnumerable<ScriptItemResponseModel> responseModels = _fileItemPresentationModelFactory.CreateScriptItemResponseModels(paths);
|
||||
IEnumerable<ScriptItemResponseModel> responseModels = _fileItemPresentationFactory.CreateScriptItemResponseModels(paths);
|
||||
return await Task.FromResult(Ok(responseModels));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ namespace Umbraco.Cms.Api.Management.Controllers.StaticFile.Item;
|
||||
[ApiVersion("1.0")]
|
||||
public class ItemStaticFileItemController : StaticFileItemControllerBase
|
||||
{
|
||||
private readonly IFileItemPresentationModelFactory _fileItemPresentationModelFactory;
|
||||
private readonly IFileItemPresentationFactory _fileItemPresentationFactory;
|
||||
|
||||
public ItemStaticFileItemController(IFileItemPresentationModelFactory fileItemPresentationModelFactory)
|
||||
=> _fileItemPresentationModelFactory = fileItemPresentationModelFactory;
|
||||
public ItemStaticFileItemController(IFileItemPresentationFactory fileItemPresentationFactory)
|
||||
=> _fileItemPresentationFactory = fileItemPresentationFactory;
|
||||
|
||||
[HttpGet("item")]
|
||||
[MapToApiVersion("1.0")]
|
||||
@@ -21,7 +21,7 @@ public class ItemStaticFileItemController : StaticFileItemControllerBase
|
||||
public async Task<IActionResult> Item([FromQuery(Name = "path")] HashSet<string> paths)
|
||||
{
|
||||
paths = paths.Select(path => path.VirtualPathToSystemPath()).ToHashSet();
|
||||
IEnumerable<StaticFileItemResponseModel> responseModels = _fileItemPresentationModelFactory.CreateStaticFileItemResponseModels(paths);
|
||||
IEnumerable<StaticFileItemResponseModel> responseModels = _fileItemPresentationFactory.CreateStaticFileItemResponseModels(paths);
|
||||
return await Task.FromResult(Ok(responseModels));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ namespace Umbraco.Cms.Api.Management.Controllers.Stylesheet.Item;
|
||||
[ApiVersion("1.0")]
|
||||
public class ItemStylesheetItemController : StylesheetItemControllerBase
|
||||
{
|
||||
private readonly IFileItemPresentationModelFactory _fileItemPresentationModelFactory;
|
||||
private readonly IFileItemPresentationFactory _fileItemPresentationFactory;
|
||||
|
||||
public ItemStylesheetItemController(IFileItemPresentationModelFactory fileItemPresentationModelFactory)
|
||||
=> _fileItemPresentationModelFactory = fileItemPresentationModelFactory;
|
||||
public ItemStylesheetItemController(IFileItemPresentationFactory fileItemPresentationFactory)
|
||||
=> _fileItemPresentationFactory = fileItemPresentationFactory;
|
||||
|
||||
[HttpGet("item")]
|
||||
[MapToApiVersion("1.0")]
|
||||
@@ -21,7 +21,7 @@ public class ItemStylesheetItemController : StylesheetItemControllerBase
|
||||
public async Task<IActionResult> Item([FromQuery(Name = "path")] HashSet<string> paths)
|
||||
{
|
||||
paths = paths.Select(path => path.VirtualPathToSystemPath()).ToHashSet();
|
||||
IEnumerable<StylesheetItemResponseModel> responseModels = _fileItemPresentationModelFactory.CreateStylesheetItemResponseModels(paths);
|
||||
IEnumerable<StylesheetItemResponseModel> responseModels = _fileItemPresentationFactory.CreateStylesheetItemResponseModels(paths);
|
||||
return await Task.FromResult(Ok(responseModels));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ internal static class EntityBuilderExtensions
|
||||
{
|
||||
builder.WithCollectionBuilder<MapDefinitionCollectionBuilder>()
|
||||
.Add<ItemTypeMapDefinition>();
|
||||
builder.Services.AddUnique<IFileItemPresentationModelFactory, FileItemPresentationModelFactory>();
|
||||
builder.Services.AddUnique<IFileItemPresentationFactory, FileItemPresentationFactory>();
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ internal static class MediaBuilderExtensions
|
||||
{
|
||||
internal static IUmbracoBuilder AddMedia(this IUmbracoBuilder builder)
|
||||
{
|
||||
builder.Services.AddTransient<IMediaPresentationModelFactory, MediaPresentationModelFactory>();
|
||||
builder.Services.AddTransient<IMediaPresentationFactory, MediaPresentationFactory>();
|
||||
builder.Services.AddTransient<IMediaEditingPresentationFactory, MediaEditingPresentationFactory>();
|
||||
builder.Services.AddTransient<IUrlAssembler, DefaultUrlAssembler>();
|
||||
builder.Services.AddScoped<IAbsoluteUrlBuilder, DefaultAbsoluteUrlBuilder>();
|
||||
|
||||
@@ -9,12 +9,12 @@ using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Api.Management.Factories;
|
||||
|
||||
public class FileItemPresentationModelFactory : IFileItemPresentationModelFactory
|
||||
public class FileItemPresentationFactory : IFileItemPresentationFactory
|
||||
{
|
||||
private readonly FileSystems _fileSystems;
|
||||
private readonly IPhysicalFileSystem _physicalFileSystem;
|
||||
|
||||
public FileItemPresentationModelFactory(FileSystems fileSystems, IPhysicalFileSystem physicalFileSystem)
|
||||
public FileItemPresentationFactory(FileSystems fileSystems, IPhysicalFileSystem physicalFileSystem)
|
||||
{
|
||||
_fileSystems = fileSystems;
|
||||
_physicalFileSystem = physicalFileSystem;
|
||||
@@ -2,11 +2,10 @@
|
||||
using Umbraco.Cms.Api.Management.ViewModels.Script.Item;
|
||||
using Umbraco.Cms.Api.Management.ViewModels.StaticFile.Item;
|
||||
using Umbraco.Cms.Api.Management.ViewModels.Stylesheet.Item;
|
||||
using Umbraco.Cms.Core.IO;
|
||||
|
||||
namespace Umbraco.Cms.Api.Management.Factories;
|
||||
|
||||
public interface IFileItemPresentationModelFactory
|
||||
public interface IFileItemPresentationFactory
|
||||
{
|
||||
IEnumerable<PartialViewItemResponseModel> CreatePartialViewItemResponseModels(IEnumerable<string> path);
|
||||
|
||||
@@ -7,7 +7,7 @@ using Umbraco.Cms.Core.Models.Entities;
|
||||
|
||||
namespace Umbraco.Cms.Api.Management.Factories;
|
||||
|
||||
public interface IMediaPresentationModelFactory
|
||||
public interface IMediaPresentationFactory
|
||||
{
|
||||
Task<MediaResponseModel> CreateResponseModelAsync(IMedia media);
|
||||
|
||||
@@ -14,8 +14,8 @@ using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Api.Management.Factories;
|
||||
|
||||
internal sealed class MediaPresentationModelFactory
|
||||
: ContentPresentationFactoryBase<IMediaType, IMediaTypeService>, IMediaPresentationModelFactory
|
||||
internal sealed class MediaPresentationFactory
|
||||
: ContentPresentationFactoryBase<IMediaType, IMediaTypeService>, IMediaPresentationFactory
|
||||
{
|
||||
private readonly IUmbracoMapper _umbracoMapper;
|
||||
private readonly ContentSettings _contentSettings;
|
||||
@@ -23,7 +23,7 @@ internal sealed class MediaPresentationModelFactory
|
||||
private readonly IAbsoluteUrlBuilder _absoluteUrlBuilder;
|
||||
private readonly IMediaTypeService _mediaTypeService;
|
||||
|
||||
public MediaPresentationModelFactory(
|
||||
public MediaPresentationFactory(
|
||||
IUmbracoMapper umbracoMapper,
|
||||
IOptions<ContentSettings> contentSettings,
|
||||
MediaUrlGeneratorCollection mediaUrlGenerators,
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace Umbraco.Cms.Core.Services.OperationStatus;
|
||||
|
||||
public enum ContentCreatingOperationStatus
|
||||
{
|
||||
Success,
|
||||
NotFound
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Asp.Versioning.Mvc" />
|
||||
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" />
|
||||
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" />
|
||||
<PackageReference Include="Dazinator.Extensions.FileProviders" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" />
|
||||
|
||||
Reference in New Issue
Block a user