From a56acb9c6d3dbbaa8fdd4ac71e68cdbd6980d15f Mon Sep 17 00:00:00 2001 From: Sven Geusens Date: Mon, 26 Feb 2024 10:20:08 +0100 Subject: [PATCH 1/4] First go at the document url controller Added optimizations for documenturlFactory --- .../Document/DocumentUrlController.cs | 36 +++++++++++++++++++ .../Factories/DocumentUrlFactory.cs | 4 +-- 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 src/Umbraco.Cms.Api.Management/Controllers/Document/DocumentUrlController.cs diff --git a/src/Umbraco.Cms.Api.Management/Controllers/Document/DocumentUrlController.cs b/src/Umbraco.Cms.Api.Management/Controllers/Document/DocumentUrlController.cs new file mode 100644 index 000000000000..868e831dab30 --- /dev/null +++ b/src/Umbraco.Cms.Api.Management/Controllers/Document/DocumentUrlController.cs @@ -0,0 +1,36 @@ +using Asp.Versioning; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Umbraco.Cms.Api.Management.Factories; +using Umbraco.Cms.Api.Management.ViewModels.Document; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Services; +using Umbraco.Extensions; + +namespace Umbraco.Cms.Api.Management.Controllers.Document; + +[ApiVersion("1.0")] +public class DocumentUrlController : DocumentControllerBase +{ + private readonly IContentService _contentService; + private readonly IDocumentUrlFactory _documentUrlFactory; + + public DocumentUrlController( + IContentService contentService, + IDocumentUrlFactory documentUrlFactory) + { + _contentService = contentService; + _documentUrlFactory = documentUrlFactory; + } + + [HttpGet] + [MapToApiVersion("1.0")] + [HttpGet("urls")] + [ProducesResponseType(typeof(Dictionary), StatusCodes.Status200OK)] + public async Task GetUrls([FromQuery(Name = "id")] HashSet ids) + { + IEnumerable items = _contentService.GetByIds(ids); + + return Ok(await items.ToDictionaryAsync(content => content.Key, async content => await _documentUrlFactory.GetUrlsAsync(content))); + } +} diff --git a/src/Umbraco.Cms.Api.Management/Factories/DocumentUrlFactory.cs b/src/Umbraco.Cms.Api.Management/Factories/DocumentUrlFactory.cs index 84beb18134b4..d18376c6e921 100644 --- a/src/Umbraco.Cms.Api.Management/Factories/DocumentUrlFactory.cs +++ b/src/Umbraco.Cms.Api.Management/Factories/DocumentUrlFactory.cs @@ -48,7 +48,7 @@ public async Task> GetUrlsAsync(IContent content) { IUmbracoContext umbracoContext = _umbracoContextAccessor.GetRequiredUmbracoContext(); - UrlInfo[] urlInfos = (await content.GetContentUrlsAsync( + IEnumerable urlInfos = await content.GetContentUrlsAsync( _publishedRouter, umbracoContext, _languageService, @@ -57,7 +57,7 @@ public async Task> GetUrlsAsync(IContent content) _variationContextAccessor, _loggerFactory.CreateLogger(), _uriUtility, - _publishedUrlProvider)).ToArray(); + _publishedUrlProvider); return urlInfos .Where(urlInfo => urlInfo.IsUrl) From dcadfd4bdb15f3f40978e74ce8ecb5f6367f9ac2 Mon Sep 17 00:00:00 2001 From: Sven Geusens Date: Tue, 5 Mar 2024 09:22:10 +0100 Subject: [PATCH 2/4] Updated Document Url endpoint Duplicated the endpoint for media Cleaned up some code marked async that will never hit a long running operation --- .../Document/DocumentUrlController.cs | 4 +- .../Controllers/Media/ByKeyMediaController.cs | 2 +- .../Controllers/Media/MediaUrlController.cs | 35 ++++++++++++++ .../MediaBuilderExtensions.cs | 1 + .../Factories/DocumentPresentationFactory.cs | 2 +- .../Factories/DocumentUrlFactory.cs | 15 +++++- .../Factories/IDocumentUrlFactory.cs | 3 +- .../Factories/IMediaPresentationFactory.cs | 2 +- .../Factories/IMediaUrlFactory.cs | 10 ++++ .../Factories/MediaPresentationFactory.cs | 28 +++-------- .../Factories/MediaUrlFactory.cs | 48 +++++++++++++++++++ .../Document/DocumentUrlInfoResourceSet.cs | 14 ++++++ .../Media/MediaUrlInfoResourceSet.cs | 14 ++++++ 13 files changed, 150 insertions(+), 28 deletions(-) create mode 100644 src/Umbraco.Cms.Api.Management/Controllers/Media/MediaUrlController.cs create mode 100644 src/Umbraco.Cms.Api.Management/Factories/IMediaUrlFactory.cs create mode 100644 src/Umbraco.Cms.Api.Management/Factories/MediaUrlFactory.cs create mode 100644 src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentUrlInfoResourceSet.cs create mode 100644 src/Umbraco.Cms.Api.Management/ViewModels/Media/MediaUrlInfoResourceSet.cs diff --git a/src/Umbraco.Cms.Api.Management/Controllers/Document/DocumentUrlController.cs b/src/Umbraco.Cms.Api.Management/Controllers/Document/DocumentUrlController.cs index 868e831dab30..91557e3b7db7 100644 --- a/src/Umbraco.Cms.Api.Management/Controllers/Document/DocumentUrlController.cs +++ b/src/Umbraco.Cms.Api.Management/Controllers/Document/DocumentUrlController.cs @@ -26,11 +26,11 @@ public DocumentUrlController( [HttpGet] [MapToApiVersion("1.0")] [HttpGet("urls")] - [ProducesResponseType(typeof(Dictionary), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] public async Task GetUrls([FromQuery(Name = "id")] HashSet ids) { IEnumerable items = _contentService.GetByIds(ids); - return Ok(await items.ToDictionaryAsync(content => content.Key, async content => await _documentUrlFactory.GetUrlsAsync(content))); + return Ok(await _documentUrlFactory.CreateUrlSetsAsync(items)); } } diff --git a/src/Umbraco.Cms.Api.Management/Controllers/Media/ByKeyMediaController.cs b/src/Umbraco.Cms.Api.Management/Controllers/Media/ByKeyMediaController.cs index 089ceb99fa8b..bee5be5d61ae 100644 --- a/src/Umbraco.Cms.Api.Management/Controllers/Media/ByKeyMediaController.cs +++ b/src/Umbraco.Cms.Api.Management/Controllers/Media/ByKeyMediaController.cs @@ -52,7 +52,7 @@ public async Task ByKey(Guid id) return MediaNotFound(); } - MediaResponseModel model = await _mediaPresentationFactory.CreateResponseModelAsync(media); + MediaResponseModel model = _mediaPresentationFactory.CreateResponseModel(media); return Ok(model); } } diff --git a/src/Umbraco.Cms.Api.Management/Controllers/Media/MediaUrlController.cs b/src/Umbraco.Cms.Api.Management/Controllers/Media/MediaUrlController.cs new file mode 100644 index 000000000000..999e0733c572 --- /dev/null +++ b/src/Umbraco.Cms.Api.Management/Controllers/Media/MediaUrlController.cs @@ -0,0 +1,35 @@ +using Asp.Versioning; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Umbraco.Cms.Api.Management.Factories; +using Umbraco.Cms.Api.Management.ViewModels.Media; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Services; + +namespace Umbraco.Cms.Api.Management.Controllers.Media; + +[ApiVersion("1.0")] +public class MediaUrlController : MediaControllerBase +{ + private readonly IMediaService _mediaService; + private readonly IMediaUrlFactory _mediaUrlFactory; + + public MediaUrlController( + IMediaService mediaService, + IMediaUrlFactory mediaUrlFactory) + { + _mediaService = mediaService; + _mediaUrlFactory = mediaUrlFactory; + } + + [HttpGet] + [MapToApiVersion("1.0")] + [HttpGet("urls")] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + public ActionResult GetUrls([FromQuery(Name = "id")] HashSet ids) + { + IEnumerable items = _mediaService.GetByIds(ids); + + return Ok(_mediaUrlFactory.CreateUrlSets(items)); + } +} diff --git a/src/Umbraco.Cms.Api.Management/DependencyInjection/MediaBuilderExtensions.cs b/src/Umbraco.Cms.Api.Management/DependencyInjection/MediaBuilderExtensions.cs index 4cdf2f6e140b..59dc5063eedb 100644 --- a/src/Umbraco.Cms.Api.Management/DependencyInjection/MediaBuilderExtensions.cs +++ b/src/Umbraco.Cms.Api.Management/DependencyInjection/MediaBuilderExtensions.cs @@ -15,6 +15,7 @@ internal static IUmbracoBuilder AddMedia(this IUmbracoBuilder builder) builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); + builder.Services.AddTransient(); builder.Services.AddScoped(); builder.WithCollectionBuilder().Add(); diff --git a/src/Umbraco.Cms.Api.Management/Factories/DocumentPresentationFactory.cs b/src/Umbraco.Cms.Api.Management/Factories/DocumentPresentationFactory.cs index f6d8b7026e17..12ee472c8c36 100644 --- a/src/Umbraco.Cms.Api.Management/Factories/DocumentPresentationFactory.cs +++ b/src/Umbraco.Cms.Api.Management/Factories/DocumentPresentationFactory.cs @@ -47,7 +47,7 @@ public async Task CreateResponseModelAsync(IContent conte { DocumentResponseModel responseModel = _umbracoMapper.Map(content)!; - responseModel.Urls = await _documentUrlFactory.GetUrlsAsync(content); + responseModel.Urls = await _documentUrlFactory.CreateUrlsAsync(content); Guid? templateKey = content.TemplateId.HasValue ? _fileService.GetTemplate(content.TemplateId.Value)?.Key diff --git a/src/Umbraco.Cms.Api.Management/Factories/DocumentUrlFactory.cs b/src/Umbraco.Cms.Api.Management/Factories/DocumentUrlFactory.cs index d18376c6e921..da8935c530fa 100644 --- a/src/Umbraco.Cms.Api.Management/Factories/DocumentUrlFactory.cs +++ b/src/Umbraco.Cms.Api.Management/Factories/DocumentUrlFactory.cs @@ -44,7 +44,7 @@ public DocumentUrlFactory( _publishedUrlProvider = publishedUrlProvider; } - public async Task> GetUrlsAsync(IContent content) + public async Task> CreateUrlsAsync(IContent content) { IUmbracoContext umbracoContext = _umbracoContextAccessor.GetRequiredUmbracoContext(); @@ -64,4 +64,17 @@ public async Task> GetUrlsAsync(IContent content) .Select(urlInfo => new DocumentUrlInfo { Culture = urlInfo.Culture, Url = urlInfo.Text }) .ToArray(); } + + public async Task> CreateUrlSetsAsync(IEnumerable contentItems) + { + var documentUrlInfoResourceSets = new List(); + + foreach (IContent content in contentItems) + { + IEnumerable urls = await CreateUrlsAsync(content); + documentUrlInfoResourceSets.Add(new DocumentUrlInfoResourceSet(content.Key, urls)); + } + + return documentUrlInfoResourceSets; + } } diff --git a/src/Umbraco.Cms.Api.Management/Factories/IDocumentUrlFactory.cs b/src/Umbraco.Cms.Api.Management/Factories/IDocumentUrlFactory.cs index aa550961177a..22dbdf383785 100644 --- a/src/Umbraco.Cms.Api.Management/Factories/IDocumentUrlFactory.cs +++ b/src/Umbraco.Cms.Api.Management/Factories/IDocumentUrlFactory.cs @@ -5,5 +5,6 @@ namespace Umbraco.Cms.Api.Management.Factories; public interface IDocumentUrlFactory { - Task> GetUrlsAsync(IContent content); + Task> CreateUrlsAsync(IContent content); + Task> CreateUrlSetsAsync(IEnumerable contentItems); } diff --git a/src/Umbraco.Cms.Api.Management/Factories/IMediaPresentationFactory.cs b/src/Umbraco.Cms.Api.Management/Factories/IMediaPresentationFactory.cs index 76faa64dbc65..a0ed0e7c4a49 100644 --- a/src/Umbraco.Cms.Api.Management/Factories/IMediaPresentationFactory.cs +++ b/src/Umbraco.Cms.Api.Management/Factories/IMediaPresentationFactory.cs @@ -9,7 +9,7 @@ namespace Umbraco.Cms.Api.Management.Factories; public interface IMediaPresentationFactory { - Task CreateResponseModelAsync(IMedia media); + MediaResponseModel CreateResponseModel(IMedia media); MediaItemResponseModel CreateItemResponseModel(IMediaEntitySlim entity); diff --git a/src/Umbraco.Cms.Api.Management/Factories/IMediaUrlFactory.cs b/src/Umbraco.Cms.Api.Management/Factories/IMediaUrlFactory.cs new file mode 100644 index 000000000000..2cdb411eea1a --- /dev/null +++ b/src/Umbraco.Cms.Api.Management/Factories/IMediaUrlFactory.cs @@ -0,0 +1,10 @@ +using Umbraco.Cms.Api.Management.ViewModels.Media; +using Umbraco.Cms.Core.Models; + +namespace Umbraco.Cms.Api.Management.Factories; + +public interface IMediaUrlFactory +{ + IEnumerable CreateUrls(IMedia media); + IEnumerable CreateUrlSets(IEnumerable mediaItems); +} diff --git a/src/Umbraco.Cms.Api.Management/Factories/MediaPresentationFactory.cs b/src/Umbraco.Cms.Api.Management/Factories/MediaPresentationFactory.cs index a195537942c0..4285fc03c44e 100644 --- a/src/Umbraco.Cms.Api.Management/Factories/MediaPresentationFactory.cs +++ b/src/Umbraco.Cms.Api.Management/Factories/MediaPresentationFactory.cs @@ -18,41 +18,27 @@ internal sealed class MediaPresentationFactory : ContentPresentationFactoryBase, IMediaPresentationFactory { private readonly IUmbracoMapper _umbracoMapper; - private readonly ContentSettings _contentSettings; - private readonly MediaUrlGeneratorCollection _mediaUrlGenerators; - private readonly IAbsoluteUrlBuilder _absoluteUrlBuilder; private readonly IMediaTypeService _mediaTypeService; + private readonly IMediaUrlFactory _mediaUrlFactory; public MediaPresentationFactory( IUmbracoMapper umbracoMapper, - IOptions contentSettings, - MediaUrlGeneratorCollection mediaUrlGenerators, - IAbsoluteUrlBuilder absoluteUrlBuilder, - IMediaTypeService mediaTypeService) + IMediaTypeService mediaTypeService, + IMediaUrlFactory mediaUrlFactory) : base(mediaTypeService, umbracoMapper) { _umbracoMapper = umbracoMapper; - _contentSettings = contentSettings.Value; - _mediaUrlGenerators = mediaUrlGenerators; - _absoluteUrlBuilder = absoluteUrlBuilder; _mediaTypeService = mediaTypeService; + _mediaUrlFactory = mediaUrlFactory; } - public Task CreateResponseModelAsync(IMedia media) + public MediaResponseModel CreateResponseModel(IMedia media) { MediaResponseModel responseModel = _umbracoMapper.Map(media)!; - responseModel.Urls = media - .GetUrls(_contentSettings, _mediaUrlGenerators) - .WhereNotNull() - .Select(mediaUrl => new MediaUrlInfo - { - Culture = null, - Url = _absoluteUrlBuilder.ToAbsoluteUrl(mediaUrl).ToString(), - }) - .ToArray(); + responseModel.Urls = _mediaUrlFactory.CreateUrls(media); - return Task.FromResult(responseModel); + return responseModel; } public MediaItemResponseModel CreateItemResponseModel(IMediaEntitySlim entity) diff --git a/src/Umbraco.Cms.Api.Management/Factories/MediaUrlFactory.cs b/src/Umbraco.Cms.Api.Management/Factories/MediaUrlFactory.cs new file mode 100644 index 000000000000..620150e70c6f --- /dev/null +++ b/src/Umbraco.Cms.Api.Management/Factories/MediaUrlFactory.cs @@ -0,0 +1,48 @@ +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Umbraco.Cms.Api.Management.Routing; +using Umbraco.Cms.Api.Management.ViewModels.Content; +using Umbraco.Cms.Api.Management.ViewModels.Document; +using Umbraco.Cms.Api.Management.ViewModels.Media; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Models.PublishedContent; +using Umbraco.Cms.Core.PropertyEditors; +using Umbraco.Cms.Core.Routing; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Web; +using Umbraco.Extensions; + +namespace Umbraco.Cms.Api.Management.Factories; + +public class MediaUrlFactory : IMediaUrlFactory +{ + private readonly ContentSettings _contentSettings; + private readonly MediaUrlGeneratorCollection _mediaUrlGenerators; + private readonly IAbsoluteUrlBuilder _absoluteUrlBuilder; + + + public MediaUrlFactory( + IOptions contentSettings, + MediaUrlGeneratorCollection mediaUrlGenerators, + IAbsoluteUrlBuilder absoluteUrlBuilder) + { + _contentSettings = contentSettings.Value; + _mediaUrlGenerators = mediaUrlGenerators; + _absoluteUrlBuilder = absoluteUrlBuilder; + } + + public IEnumerable CreateUrls(IMedia media) => + media + .GetUrls(_contentSettings, _mediaUrlGenerators) + .WhereNotNull() + .Select(mediaUrl => new MediaUrlInfo + { + Culture = null, + Url = _absoluteUrlBuilder.ToAbsoluteUrl(mediaUrl).ToString(), + }) + .ToArray(); + + public IEnumerable CreateUrlSets(IEnumerable mediaItems) => + mediaItems.Select(media => new MediaUrlInfoResourceSet(media.Key, CreateUrls(media))).ToArray(); +} diff --git a/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentUrlInfoResourceSet.cs b/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentUrlInfoResourceSet.cs new file mode 100644 index 000000000000..adad298ead20 --- /dev/null +++ b/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentUrlInfoResourceSet.cs @@ -0,0 +1,14 @@ +namespace Umbraco.Cms.Api.Management.ViewModels.Document; + +public sealed class DocumentUrlInfoResourceSet +{ + public DocumentUrlInfoResourceSet(Guid id, IEnumerable urlInfos) + { + Id = id; + UrlInfos = urlInfos; + } + + public Guid Id { get; } + + public IEnumerable UrlInfos { get; } +} diff --git a/src/Umbraco.Cms.Api.Management/ViewModels/Media/MediaUrlInfoResourceSet.cs b/src/Umbraco.Cms.Api.Management/ViewModels/Media/MediaUrlInfoResourceSet.cs new file mode 100644 index 000000000000..4078b8824a81 --- /dev/null +++ b/src/Umbraco.Cms.Api.Management/ViewModels/Media/MediaUrlInfoResourceSet.cs @@ -0,0 +1,14 @@ +namespace Umbraco.Cms.Api.Management.ViewModels.Media; + +public sealed class MediaUrlInfoResourceSet +{ + public MediaUrlInfoResourceSet(Guid id, IEnumerable urlInfos) + { + Id = id; + UrlInfos = urlInfos; + } + + public Guid Id { get; } + + public IEnumerable UrlInfos { get; } +} From 165f06bba6ceca0f0d1f8f61e37e61f282d4e3a5 Mon Sep 17 00:00:00 2001 From: Sven Geusens Date: Tue, 5 Mar 2024 10:46:57 +0100 Subject: [PATCH 3/4] Remove dupplicate attributes --- .../Controllers/Document/DocumentUrlController.cs | 1 - .../Controllers/Media/MediaUrlController.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Umbraco.Cms.Api.Management/Controllers/Document/DocumentUrlController.cs b/src/Umbraco.Cms.Api.Management/Controllers/Document/DocumentUrlController.cs index 91557e3b7db7..cff89c9bf1f9 100644 --- a/src/Umbraco.Cms.Api.Management/Controllers/Document/DocumentUrlController.cs +++ b/src/Umbraco.Cms.Api.Management/Controllers/Document/DocumentUrlController.cs @@ -23,7 +23,6 @@ public DocumentUrlController( _documentUrlFactory = documentUrlFactory; } - [HttpGet] [MapToApiVersion("1.0")] [HttpGet("urls")] [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] diff --git a/src/Umbraco.Cms.Api.Management/Controllers/Media/MediaUrlController.cs b/src/Umbraco.Cms.Api.Management/Controllers/Media/MediaUrlController.cs index 999e0733c572..1851ab5ef4dc 100644 --- a/src/Umbraco.Cms.Api.Management/Controllers/Media/MediaUrlController.cs +++ b/src/Umbraco.Cms.Api.Management/Controllers/Media/MediaUrlController.cs @@ -22,7 +22,6 @@ public MediaUrlController( _mediaUrlFactory = mediaUrlFactory; } - [HttpGet] [MapToApiVersion("1.0")] [HttpGet("urls")] [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] From 0731083f869bbfe0387b3301b8070ff8b3a0aa76 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Date: Wed, 10 Apr 2024 14:27:37 +0200 Subject: [PATCH 4/4] Rename resource sets to response model --- .../Controllers/Document/DocumentUrlController.cs | 2 +- .../Controllers/Media/MediaUrlController.cs | 2 +- .../Factories/DocumentUrlFactory.cs | 6 +++--- .../Factories/IDocumentUrlFactory.cs | 2 +- .../Factories/IMediaUrlFactory.cs | 2 +- src/Umbraco.Cms.Api.Management/Factories/MediaUrlFactory.cs | 4 ++-- ...rlInfoResourceSet.cs => DocumentUrlInfoResponseModel.cs} | 4 ++-- ...iaUrlInfoResourceSet.cs => MediaUrlInfoResponseModel.cs} | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) rename src/Umbraco.Cms.Api.Management/ViewModels/Document/{DocumentUrlInfoResourceSet.cs => DocumentUrlInfoResponseModel.cs} (60%) rename src/Umbraco.Cms.Api.Management/ViewModels/Media/{MediaUrlInfoResourceSet.cs => MediaUrlInfoResponseModel.cs} (61%) diff --git a/src/Umbraco.Cms.Api.Management/Controllers/Document/DocumentUrlController.cs b/src/Umbraco.Cms.Api.Management/Controllers/Document/DocumentUrlController.cs index cff89c9bf1f9..9d0b88a2e105 100644 --- a/src/Umbraco.Cms.Api.Management/Controllers/Document/DocumentUrlController.cs +++ b/src/Umbraco.Cms.Api.Management/Controllers/Document/DocumentUrlController.cs @@ -25,7 +25,7 @@ public DocumentUrlController( [MapToApiVersion("1.0")] [HttpGet("urls")] - [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] public async Task GetUrls([FromQuery(Name = "id")] HashSet ids) { IEnumerable items = _contentService.GetByIds(ids); diff --git a/src/Umbraco.Cms.Api.Management/Controllers/Media/MediaUrlController.cs b/src/Umbraco.Cms.Api.Management/Controllers/Media/MediaUrlController.cs index 1851ab5ef4dc..1edd8d40553c 100644 --- a/src/Umbraco.Cms.Api.Management/Controllers/Media/MediaUrlController.cs +++ b/src/Umbraco.Cms.Api.Management/Controllers/Media/MediaUrlController.cs @@ -24,7 +24,7 @@ public MediaUrlController( [MapToApiVersion("1.0")] [HttpGet("urls")] - [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] public ActionResult GetUrls([FromQuery(Name = "id")] HashSet ids) { IEnumerable items = _mediaService.GetByIds(ids); diff --git a/src/Umbraco.Cms.Api.Management/Factories/DocumentUrlFactory.cs b/src/Umbraco.Cms.Api.Management/Factories/DocumentUrlFactory.cs index da8935c530fa..cee548ed5ca5 100644 --- a/src/Umbraco.Cms.Api.Management/Factories/DocumentUrlFactory.cs +++ b/src/Umbraco.Cms.Api.Management/Factories/DocumentUrlFactory.cs @@ -65,14 +65,14 @@ public async Task> CreateUrlsAsync(IContent content .ToArray(); } - public async Task> CreateUrlSetsAsync(IEnumerable contentItems) + public async Task> CreateUrlSetsAsync(IEnumerable contentItems) { - var documentUrlInfoResourceSets = new List(); + var documentUrlInfoResourceSets = new List(); foreach (IContent content in contentItems) { IEnumerable urls = await CreateUrlsAsync(content); - documentUrlInfoResourceSets.Add(new DocumentUrlInfoResourceSet(content.Key, urls)); + documentUrlInfoResourceSets.Add(new DocumentUrlInfoResponseModel(content.Key, urls)); } return documentUrlInfoResourceSets; diff --git a/src/Umbraco.Cms.Api.Management/Factories/IDocumentUrlFactory.cs b/src/Umbraco.Cms.Api.Management/Factories/IDocumentUrlFactory.cs index 22dbdf383785..f87a0aaec8bf 100644 --- a/src/Umbraco.Cms.Api.Management/Factories/IDocumentUrlFactory.cs +++ b/src/Umbraco.Cms.Api.Management/Factories/IDocumentUrlFactory.cs @@ -6,5 +6,5 @@ namespace Umbraco.Cms.Api.Management.Factories; public interface IDocumentUrlFactory { Task> CreateUrlsAsync(IContent content); - Task> CreateUrlSetsAsync(IEnumerable contentItems); + Task> CreateUrlSetsAsync(IEnumerable contentItems); } diff --git a/src/Umbraco.Cms.Api.Management/Factories/IMediaUrlFactory.cs b/src/Umbraco.Cms.Api.Management/Factories/IMediaUrlFactory.cs index 2cdb411eea1a..a15905edb3b5 100644 --- a/src/Umbraco.Cms.Api.Management/Factories/IMediaUrlFactory.cs +++ b/src/Umbraco.Cms.Api.Management/Factories/IMediaUrlFactory.cs @@ -6,5 +6,5 @@ namespace Umbraco.Cms.Api.Management.Factories; public interface IMediaUrlFactory { IEnumerable CreateUrls(IMedia media); - IEnumerable CreateUrlSets(IEnumerable mediaItems); + IEnumerable CreateUrlSets(IEnumerable mediaItems); } diff --git a/src/Umbraco.Cms.Api.Management/Factories/MediaUrlFactory.cs b/src/Umbraco.Cms.Api.Management/Factories/MediaUrlFactory.cs index 620150e70c6f..b1e9406289db 100644 --- a/src/Umbraco.Cms.Api.Management/Factories/MediaUrlFactory.cs +++ b/src/Umbraco.Cms.Api.Management/Factories/MediaUrlFactory.cs @@ -43,6 +43,6 @@ public IEnumerable CreateUrls(IMedia media) => }) .ToArray(); - public IEnumerable CreateUrlSets(IEnumerable mediaItems) => - mediaItems.Select(media => new MediaUrlInfoResourceSet(media.Key, CreateUrls(media))).ToArray(); + public IEnumerable CreateUrlSets(IEnumerable mediaItems) => + mediaItems.Select(media => new MediaUrlInfoResponseModel(media.Key, CreateUrls(media))).ToArray(); } diff --git a/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentUrlInfoResourceSet.cs b/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentUrlInfoResponseModel.cs similarity index 60% rename from src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentUrlInfoResourceSet.cs rename to src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentUrlInfoResponseModel.cs index adad298ead20..dc8a501d163f 100644 --- a/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentUrlInfoResourceSet.cs +++ b/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentUrlInfoResponseModel.cs @@ -1,8 +1,8 @@ namespace Umbraco.Cms.Api.Management.ViewModels.Document; -public sealed class DocumentUrlInfoResourceSet +public sealed class DocumentUrlInfoResponseModel { - public DocumentUrlInfoResourceSet(Guid id, IEnumerable urlInfos) + public DocumentUrlInfoResponseModel(Guid id, IEnumerable urlInfos) { Id = id; UrlInfos = urlInfos; diff --git a/src/Umbraco.Cms.Api.Management/ViewModels/Media/MediaUrlInfoResourceSet.cs b/src/Umbraco.Cms.Api.Management/ViewModels/Media/MediaUrlInfoResponseModel.cs similarity index 61% rename from src/Umbraco.Cms.Api.Management/ViewModels/Media/MediaUrlInfoResourceSet.cs rename to src/Umbraco.Cms.Api.Management/ViewModels/Media/MediaUrlInfoResponseModel.cs index 4078b8824a81..f65231bb47e6 100644 --- a/src/Umbraco.Cms.Api.Management/ViewModels/Media/MediaUrlInfoResourceSet.cs +++ b/src/Umbraco.Cms.Api.Management/ViewModels/Media/MediaUrlInfoResponseModel.cs @@ -1,8 +1,8 @@ namespace Umbraco.Cms.Api.Management.ViewModels.Media; -public sealed class MediaUrlInfoResourceSet +public sealed class MediaUrlInfoResponseModel { - public MediaUrlInfoResourceSet(Guid id, IEnumerable urlInfos) + public MediaUrlInfoResponseModel(Guid id, IEnumerable urlInfos) { Id = id; UrlInfos = urlInfos;