From 23ffd501690b99f03f9cc1f0dd82f40c57ccee1f Mon Sep 17 00:00:00 2001 From: griffri Date: Mon, 12 Feb 2024 16:22:11 +0000 Subject: [PATCH 1/4] Replace DeliveryChannels with WcDeliveryChannels in Image + usages, remove OldDeliveryChannels --- .../Converters/AssetConverterTests.cs | 4 +-- .../Validation/HydraImageValidatorTests.cs | 32 +++++++++---------- .../ImageBatchPatchValidatorTests.cs | 4 +-- .../Integration/CustomerQueueTests.cs | 4 +-- .../API.Tests/Integration/ModifyAssetTests.cs | 10 +++--- ...ModifyAssetWithoutDeliveryChannelsTests.cs | 8 ++--- .../API/Converters/AssetConverter.cs | 6 ++-- .../API/Converters/LegacyModeConverter.cs | 2 +- .../API/Features/Image/ImageController.cs | 2 +- .../Image/Validation/HydraImageValidator.cs | 16 +++++----- .../Validation/ImageBatchPatchValidator.cs | 2 +- src/protagonist/DLCS.HydraModel/Image.cs | 10 +----- 12 files changed, 44 insertions(+), 56 deletions(-) diff --git a/src/protagonist/API.Tests/Converters/AssetConverterTests.cs b/src/protagonist/API.Tests/Converters/AssetConverterTests.cs index ea15b3316..f0fb336b2 100644 --- a/src/protagonist/API.Tests/Converters/AssetConverterTests.cs +++ b/src/protagonist/API.Tests/Converters/AssetConverterTests.cs @@ -133,7 +133,7 @@ public void ToDlcsModel_All_Fields_Should_Convert() MaxUnauthorised = 400, MediaType = mediaType, ThumbnailPolicy = thumbnailPolicy, - DeliveryChannels = deliveryChannel + WcDeliveryChannels = deliveryChannel }; var asset = hydraImage.ToDlcsModel(1); @@ -174,7 +174,7 @@ public void ToDlcsModel_ReordersDeliveryChannel() { Id = AssetApiId, Space = 99, - DeliveryChannels = deliveryChannel + WcDeliveryChannels = deliveryChannel }; // Act diff --git a/src/protagonist/API.Tests/Features/Images/Validation/HydraImageValidatorTests.cs b/src/protagonist/API.Tests/Features/Images/Validation/HydraImageValidatorTests.cs index 5848a4604..5fd91671c 100644 --- a/src/protagonist/API.Tests/Features/Images/Validation/HydraImageValidatorTests.cs +++ b/src/protagonist/API.Tests/Features/Images/Validation/HydraImageValidatorTests.cs @@ -54,7 +54,7 @@ public void Width_Provided_NotFileOnly_OrAudio(string mediaType, string dc) { var model = new DLCS.HydraModel.Image { - Width = 10, DeliveryChannels = dc.Split(","), MediaType = mediaType + Width = 10, WcDeliveryChannels = dc.Split(","), MediaType = mediaType }; var result = sut.TestValidate(model); result @@ -70,7 +70,7 @@ public void Width_Allowed_IfFileOnly_AndVideoOrImage(string mediaType) { var model = new DLCS.HydraModel.Image { - MediaType = mediaType, DeliveryChannels = new[] { "file" }, Width = 10 + MediaType = mediaType, WcDeliveryChannels = new[] { "file" }, Width = 10 }; var result = sut.TestValidate(model); result.ShouldNotHaveValidationErrorFor(a => a.Width); @@ -94,7 +94,7 @@ public void Height_Provided_NotFileOnly_OrAudio(string mediaType, string dc) { var model = new DLCS.HydraModel.Image { - Height = 10, DeliveryChannels = dc.Split(","), MediaType = mediaType + Height = 10, WcDeliveryChannels = dc.Split(","), MediaType = mediaType }; var result = sut.TestValidate(model); result @@ -110,7 +110,7 @@ public void Height_Allowed_IfFileOnly_AndVideoOrImage(string mediaType) { var model = new DLCS.HydraModel.Image { - MediaType = mediaType, DeliveryChannels = new[] { "file" }, Height = 10 + MediaType = mediaType, WcDeliveryChannels = new[] { "file" }, Height = 10 }; var result = sut.TestValidate(model); result.ShouldNotHaveValidationErrorFor(a => a.Height); @@ -134,7 +134,7 @@ public void Duration_Provided_NotFileOnly_OrImage(string mediaType, string dc) { var model = new DLCS.HydraModel.Image { - Duration = 10, DeliveryChannels = dc.Split(","), MediaType = mediaType + Duration = 10, WcDeliveryChannels = dc.Split(","), MediaType = mediaType }; var result = sut.TestValidate(model); result @@ -150,7 +150,7 @@ public void Duration_Allowed_IfFileOnly_AndVideoOrAudio(string mediaType) { var model = new DLCS.HydraModel.Image { - MediaType = mediaType, DeliveryChannels = new[] { "file" }, Duration = 10 + MediaType = mediaType, WcDeliveryChannels = new[] { "file" }, Duration = 10 }; var result = sut.TestValidate(model); result.ShouldNotHaveValidationErrorFor(a => a.Duration); @@ -180,7 +180,7 @@ public void UseOriginalPolicy_NotImage(string dc) { var model = new DLCS.HydraModel.Image { - DeliveryChannels = dc.Split(","), + WcDeliveryChannels = dc.Split(","), MediaType = "image/jpeg", ImageOptimisationPolicy = KnownImageOptimisationPolicy.UseOriginalId }; @@ -197,7 +197,7 @@ public void UseOriginalPolicy_Image(string dc) { var model = new DLCS.HydraModel.Image { - DeliveryChannels = dc.Split(","), + WcDeliveryChannels = dc.Split(","), MediaType = "image/jpeg", ImageOptimisationPolicy = KnownImageOptimisationPolicy.UseOriginalId }; @@ -210,7 +210,7 @@ public void DeliveryChannel_CanBeEmpty() { var model = new DLCS.HydraModel.Image(); var result = sut.TestValidate(model); - result.ShouldNotHaveValidationErrorFor(a => a.DeliveryChannels); + result.ShouldNotHaveValidationErrorFor(a => a.WcDeliveryChannels); } [Theory] @@ -220,17 +220,17 @@ public void DeliveryChannel_CanBeEmpty() [InlineData("file,iiif-av,iiif-img")] public void DeliveryChannel_CanContainKnownValues(string knownValues) { - var model = new DLCS.HydraModel.Image { DeliveryChannels = knownValues.Split(',') }; + var model = new DLCS.HydraModel.Image { WcDeliveryChannels = knownValues.Split(',') }; var result = sut.TestValidate(model); - result.ShouldNotHaveValidationErrorFor(a => a.DeliveryChannels); + result.ShouldNotHaveValidationErrorFor(a => a.WcDeliveryChannels); } [Fact] public void DeliveryChannel_UnknownValue() { - var model = new DLCS.HydraModel.Image { DeliveryChannels = new[] { "foo" } }; + var model = new DLCS.HydraModel.Image { WcDeliveryChannels = new[] { "foo" } }; var result = sut.TestValidate(model); - result.ShouldHaveValidationErrorFor(a => a.DeliveryChannels); + result.ShouldHaveValidationErrorFor(a => a.WcDeliveryChannels); } @@ -239,9 +239,9 @@ public void DeliveryChannel_ValidationError_WhenDeliveryChannelsDisabled() { var apiSettings = new ApiSettings(); var imageValidator = new HydraImageValidator(Options.Create(apiSettings)); - var model = new DLCS.HydraModel.Image { DeliveryChannels = new[] { "iiif-img" } }; + var model = new DLCS.HydraModel.Image { WcDeliveryChannels = new[] { "iiif-img" } }; var result = imageValidator.TestValidate(model); - result.ShouldHaveValidationErrorFor(a => a.DeliveryChannels); + result.ShouldHaveValidationErrorFor(a => a.WcDeliveryChannels); } [Fact] public void DeliveryChannel_NoValidationError_WhenDeliveryChannelsDisabled() @@ -250,6 +250,6 @@ public void DeliveryChannel_NoValidationError_WhenDeliveryChannelsDisabled() var imageValidator = new HydraImageValidator(Options.Create(apiSettings)); var model = new DLCS.HydraModel.Image(); var result = imageValidator.TestValidate(model); - result.ShouldNotHaveValidationErrorFor(a => a.DeliveryChannels); + result.ShouldNotHaveValidationErrorFor(a => a.WcDeliveryChannels); } } \ No newline at end of file diff --git a/src/protagonist/API.Tests/Features/Images/Validation/ImageBatchPatchValidatorTests.cs b/src/protagonist/API.Tests/Features/Images/Validation/ImageBatchPatchValidatorTests.cs index 7d7623190..3708fcecb 100644 --- a/src/protagonist/API.Tests/Features/Images/Validation/ImageBatchPatchValidatorTests.cs +++ b/src/protagonist/API.Tests/Features/Images/Validation/ImageBatchPatchValidatorTests.cs @@ -137,10 +137,10 @@ public void Member_DeliveryChannels_Provided() { var model = new HydraCollection { Members = new[] { - new Image { DeliveryChannels = new []{"iiif-img","thumbs"}} + new Image { WcDeliveryChannels = new []{"iiif-img","thumbs"}} } }; var result = sut.TestValidate(model); - result.ShouldHaveValidationErrorFor("Members[0].DeliveryChannels"); + result.ShouldHaveValidationErrorFor("Members[0].WcDeliveryChannels"); } [Fact] diff --git a/src/protagonist/API.Tests/Integration/CustomerQueueTests.cs b/src/protagonist/API.Tests/Integration/CustomerQueueTests.cs index 158f8ba25..e95cd161f 100644 --- a/src/protagonist/API.Tests/Integration/CustomerQueueTests.cs +++ b/src/protagonist/API.Tests/Integration/CustomerQueueTests.cs @@ -997,14 +997,14 @@ public async Task Post_CreatePriorityBatch_UpdatesQueueAndCounts() ""id"": ""one"", ""origin"": ""https://example.org/foo.jpg"", ""space"": 2, - ""deliveryChannels"": [""iiif-img""], + ""wcDeliveryChannels"": [""iiif-img""], ""family"": ""I"", ""mediaType"": ""image/jpeg"" }, { ""id"": ""two"", ""origin"": ""https://example.org/foo.png"", - ""deliveryChannels"": [""iiif-img""], + ""wcDeliveryChannels"": [""iiif-img""], ""space"": 2, ""mediaType"": ""image/png"" }, diff --git a/src/protagonist/API.Tests/Integration/ModifyAssetTests.cs b/src/protagonist/API.Tests/Integration/ModifyAssetTests.cs index 376914b5a..154c1c6fb 100644 --- a/src/protagonist/API.Tests/Integration/ModifyAssetTests.cs +++ b/src/protagonist/API.Tests/Integration/ModifyAssetTests.cs @@ -542,18 +542,16 @@ public async Task Put_New_Asset_Requires_Origin() response.StatusCode.Should().Be(HttpStatusCode.BadRequest); } - [Theory] - [InlineData("deliveryChannels")] - [InlineData("wcDeliveryChannels")] - public async Task Put_New_Asset_Supports_DeliveryChannels_Aliases(string deliveryChannelAlias) + [Fact] + public async Task Put_New_Asset_Supports_WcDeliveryChannels() { - var assetId = new AssetId(99, 1, $"{nameof(Put_New_Asset_Supports_DeliveryChannels_Aliases)}-{deliveryChannelAlias}"); + var assetId = new AssetId(99, 1, nameof(Put_New_Asset_Supports_WcDeliveryChannels)); var hydraImageBody = $@"{{ ""@type"": ""Image"", ""origin"": ""https://example.org/{assetId.Asset}.tiff"", ""family"": ""I"", ""mediaType"": ""image/tiff"", - ""{deliveryChannelAlias}"": [""file""] + ""wcDeliveryChannels"": [""file""] }}"; A.CallTo(() => diff --git a/src/protagonist/API.Tests/Integration/ModifyAssetWithoutDeliveryChannelsTests.cs b/src/protagonist/API.Tests/Integration/ModifyAssetWithoutDeliveryChannelsTests.cs index 3146f3b44..6f43ad192 100644 --- a/src/protagonist/API.Tests/Integration/ModifyAssetWithoutDeliveryChannelsTests.cs +++ b/src/protagonist/API.Tests/Integration/ModifyAssetWithoutDeliveryChannelsTests.cs @@ -32,17 +32,15 @@ public class ModifyAssetWithoutDeliveryChannelsTests : IClassFixture 0) @@ -270,9 +270,9 @@ public static Asset ToDlcsModel(this Image hydraImage, int customerId, int? spac asset.MediaType = hydraImage.MediaType; } - if (hydraImage.DeliveryChannels != null) + if (hydraImage.WcDeliveryChannels != null) { - asset.DeliveryChannels = hydraImage.DeliveryChannels.OrderBy(dc => dc).Select(dc => dc.ToLower()).ToArray(); + asset.DeliveryChannels = hydraImage.WcDeliveryChannels.OrderBy(dc => dc).Select(dc => dc.ToLower()).ToArray(); } var thumbnailPolicy = hydraImage.ThumbnailPolicy.GetLastPathElement("thumbnailPolicies/"); diff --git a/src/protagonist/API/Converters/LegacyModeConverter.cs b/src/protagonist/API/Converters/LegacyModeConverter.cs index 561a01ca5..51f20b6fb 100644 --- a/src/protagonist/API/Converters/LegacyModeConverter.cs +++ b/src/protagonist/API/Converters/LegacyModeConverter.cs @@ -26,7 +26,7 @@ public static T VerifyAndConvertToModernFormat(T image) image.MediaType = MIMEHelper.GetContentTypeForExtension(contentType) ?? DefaultMediaType; - if (image.Origin is not null && image.Family is null && image.DeliveryChannels.IsNullOrEmpty()) + if (image.Origin is not null && image.Family is null && image.WcDeliveryChannels.IsNullOrEmpty()) { image.Family = AssetFamily.Image; } diff --git a/src/protagonist/API/Features/Image/ImageController.cs b/src/protagonist/API/Features/Image/ImageController.cs index c5412138b..a0c8fab3a 100644 --- a/src/protagonist/API/Features/Image/ImageController.cs +++ b/src/protagonist/API/Features/Image/ImageController.cs @@ -152,7 +152,7 @@ public async Task GetImage(int customerId, int spaceId, string im [FromBody] DLCS.HydraModel.Image hydraAsset, CancellationToken cancellationToken) { - if (!apiSettings.DeliveryChannelsEnabled && !hydraAsset.DeliveryChannels.IsNullOrEmpty()) + if (!apiSettings.DeliveryChannelsEnabled && !hydraAsset.WcDeliveryChannels.IsNullOrEmpty()) { var assetId = new AssetId(customerId, spaceId, imageId); return this.HydraProblem("Delivery channels are disabled", assetId.ToString(), 400, "Bad Request"); diff --git a/src/protagonist/API/Features/Image/Validation/HydraImageValidator.cs b/src/protagonist/API/Features/Image/Validation/HydraImageValidator.cs index b47cb806d..d283cc150 100644 --- a/src/protagonist/API/Features/Image/Validation/HydraImageValidator.cs +++ b/src/protagonist/API/Features/Image/Validation/HydraImageValidator.cs @@ -18,7 +18,7 @@ public HydraImageValidator(IOptions apiSettings) // Required fields RuleFor(a => a.MediaType).NotEmpty().WithMessage("Media type must be specified"); - When(a => !a.DeliveryChannels.IsNullOrEmpty(), DeliveryChannelDependantValidation) + When(a => !a.WcDeliveryChannels.IsNullOrEmpty(), DeliveryChannelDependantValidation) .Otherwise(() => { RuleFor(a => a.Width).Empty().WithMessage("Should not include width"); @@ -32,11 +32,11 @@ public HydraImageValidator(IOptions apiSettings) RuleFor(a => a.Created).Empty().WithMessage("Should not include created"); // Other validation - RuleFor(a => a.DeliveryChannels).Must(d => d.IsNullOrEmpty()) + RuleFor(a => a.WcDeliveryChannels).Must(d => d.IsNullOrEmpty()) .When(_ => !apiSettings.Value.DeliveryChannelsEnabled) .WithMessage("Delivery channels are disabled"); - RuleForEach(a => a.DeliveryChannels) + RuleForEach(a => a.WcDeliveryChannels) .Must(dc => AssetDeliveryChannels.All.Contains(dc)) .WithMessage($"DeliveryChannel must be one of {AssetDeliveryChannels.AllString}"); } @@ -46,7 +46,7 @@ private void DeliveryChannelDependantValidation() { RuleFor(a => a.ImageOptimisationPolicy) .Must(iop => !KnownImageOptimisationPolicy.IsNoOpIdentifier(iop)) - .When(a => !a.DeliveryChannels.ContainsOnly(AssetDeliveryChannels.File)) + .When(a => !a.WcDeliveryChannels.ContainsOnly(AssetDeliveryChannels.File)) .WithMessage( $"ImageOptimisationPolicy {KnownImageOptimisationPolicy.NoneId} only valid for 'file' delivery channel"); @@ -54,23 +54,23 @@ private void DeliveryChannelDependantValidation() .Empty() .WithMessage("Should not include width") .Unless(a => - a.DeliveryChannels.ContainsOnly(AssetDeliveryChannels.File) && !MIMEHelper.IsAudio(a.MediaType)); + a.WcDeliveryChannels.ContainsOnly(AssetDeliveryChannels.File) && !MIMEHelper.IsAudio(a.MediaType)); RuleFor(a => a.Height) .Empty() .WithMessage("Should not include height") .Unless(a => - a.DeliveryChannels.ContainsOnly(AssetDeliveryChannels.File) && !MIMEHelper.IsAudio(a.MediaType)); + a.WcDeliveryChannels.ContainsOnly(AssetDeliveryChannels.File) && !MIMEHelper.IsAudio(a.MediaType)); RuleFor(a => a.Duration) .Empty() .WithMessage("Should not include duration") .Unless(a => - a.DeliveryChannels.ContainsOnly(AssetDeliveryChannels.File) && !MIMEHelper.IsImage(a.MediaType)); + a.WcDeliveryChannels.ContainsOnly(AssetDeliveryChannels.File) && !MIMEHelper.IsImage(a.MediaType)); RuleFor(a => a.ImageOptimisationPolicy) .Must(iop => !KnownImageOptimisationPolicy.IsUseOriginalIdentifier(iop)) - .When(a => !a.DeliveryChannels!.Contains(AssetDeliveryChannels.Image)) + .When(a => !a.WcDeliveryChannels!.Contains(AssetDeliveryChannels.Image)) .WithMessage( $"ImageOptimisationPolicy '{KnownImageOptimisationPolicy.UseOriginalId}' only valid for image delivery-channel"); } diff --git a/src/protagonist/API/Features/Image/Validation/ImageBatchPatchValidator.cs b/src/protagonist/API/Features/Image/Validation/ImageBatchPatchValidator.cs index bcf569fd3..46eda18eb 100644 --- a/src/protagonist/API/Features/Image/Validation/ImageBatchPatchValidator.cs +++ b/src/protagonist/API/Features/Image/Validation/ImageBatchPatchValidator.cs @@ -35,7 +35,7 @@ public ImageBatchPatchValidator(IOptions apiSettings) members.RuleFor(a => a.Origin).Empty().WithMessage("Origin cannot be set in a bulk patching operation"); members.RuleFor(a => a.ImageOptimisationPolicy).Empty().WithMessage("Image optimisation policies cannot be set in a bulk patching operation"); members.RuleFor(a => a.MaxUnauthorised).Empty().WithMessage("MaxUnauthorised cannot be set in a bulk patching operation"); - members.RuleFor(a => a.DeliveryChannels).Empty().WithMessage("Delivery channels cannot be set in a bulk patching operation"); + members.RuleFor(a => a.WcDeliveryChannels).Empty().WithMessage("Delivery channels cannot be set in a bulk patching operation"); members.RuleFor(a => a.ThumbnailPolicy).Empty().WithMessage("Thumbnail policy cannot be set in a bulk patching operation"); }); } diff --git a/src/protagonist/DLCS.HydraModel/Image.cs b/src/protagonist/DLCS.HydraModel/Image.cs index 4a8325e70..5e993968c 100644 --- a/src/protagonist/DLCS.HydraModel/Image.cs +++ b/src/protagonist/DLCS.HydraModel/Image.cs @@ -195,18 +195,10 @@ public Image(string baseUrl, int customerId, int space, string modelId) [JsonProperty(Order = 130, PropertyName = "textType")] public string? TextType { get; set; } // e.g., METS-ALTO, hOCR, TEI, text/plain etc - [JsonIgnore] - public string[]? DeliveryChannels { get; set; } - - [RdfProperty(Description = "Delivery channel specifying how the asset will be available.", - Range = Names.XmlSchema.String, ReadOnly = false, WriteOnly = true)] - [JsonProperty(Order = 140, PropertyName = "deliveryChannels")] - public string[]? OldDeliveryChannels { set => DeliveryChannels = value; get => DeliveryChannels; } - [RdfProperty(Description = "Delivery channel specifying how the asset will be available.", Range = Names.XmlSchema.String, ReadOnly = false, WriteOnly = false)] [JsonProperty(Order = 141, PropertyName = "wcDeliveryChannels")] - public string[]? WcDeliveryChannels { set => DeliveryChannels = value; get => DeliveryChannels; } + public string[]? WcDeliveryChannels { get; set; } [RdfProperty(Description = "The role or roles that a user must possess to view this image above maxUnauthorised. " + "These are URIs of roles e.g., https://api.dlcs.io/customers/1/roles/requiresRegistration", From 495684ec7c1d9f35f414cc3e43d489fc5a01a8a6 Mon Sep 17 00:00:00 2001 From: griffri Date: Mon, 12 Feb 2024 16:58:40 +0000 Subject: [PATCH 2/4] Add new deliveryChannel Hydra model. Add DeliveryChannels[] property to image Hydra model --- .../DLCS.HydraModel/DeliveryChannel.cs | 67 +++++++++++++++++++ src/protagonist/DLCS.HydraModel/Image.cs | 5 ++ 2 files changed, 72 insertions(+) create mode 100644 src/protagonist/DLCS.HydraModel/DeliveryChannel.cs diff --git a/src/protagonist/DLCS.HydraModel/DeliveryChannel.cs b/src/protagonist/DLCS.HydraModel/DeliveryChannel.cs new file mode 100644 index 000000000..45d37e953 --- /dev/null +++ b/src/protagonist/DLCS.HydraModel/DeliveryChannel.cs @@ -0,0 +1,67 @@ +using Hydra; +using Hydra.Model; +using Newtonsoft.Json; + +namespace DLCS.HydraModel; + +[HydraClass(typeof(DeliveryChannelClass), + Description = "A delivery channel represents a way an asset on the DLCS can be served.", + UriTemplate = "/customers/{0}/defaultDeliveryChannels/{1}, /customers/{0}/spaces/{1}/defaultDeliveryChannels/{2}")] +public class DeliveryChannel : DlcsResource +{ + public DeliveryChannel() + { + + } + + public DeliveryChannel(string baseUrl, int customerId, string deliveryChannelId, int? spaceId) + { + ModelId = deliveryChannelId; + CustomerId = customerId; + SpaceId = spaceId; + if (spaceId.HasValue) + { + Init(baseUrl, false, customerId, spaceId, deliveryChannelId); + } + else + { + Init(baseUrl, false, customerId, deliveryChannelId); + } + } + + [JsonIgnore] + public int CustomerId { get; set; } + + [JsonIgnore] + public int? SpaceId { get; set; } + + [JsonIgnore] + public string? ModelId { get; set; } + + [RdfProperty(Description = "The name of the DLCS delivery channel this is based on.", + Range = Names.XmlSchema.String, ReadOnly = false, WriteOnly = false)] + [JsonProperty(Order = 11, PropertyName = "channel")] + public string? Channel { get; set; } + + [HydraLink(Description = "The policy assigned to this delivery channel.", + Range = "vocab:deliveryChannelPolicy", ReadOnly = false, WriteOnly = false)] + [JsonProperty(Order = 12, PropertyName = "policy")] + public string? Policy { get; set; } +} + +public class DeliveryChannelClass: Class +{ + string operationId = "_:deliveryChannel_"; + + public DeliveryChannelClass() + { + BootstrapViaReflection(typeof(DeliveryChannel)); + } + + public override void DefineOperations() + { + SupportedOperations = CommonOperations.GetStandardResourceOperations( + operationId, "Delivery Channel", Id, + "GET", "PUT", "DELETE"); + } +} \ No newline at end of file diff --git a/src/protagonist/DLCS.HydraModel/Image.cs b/src/protagonist/DLCS.HydraModel/Image.cs index 5e993968c..37b7a37d4 100644 --- a/src/protagonist/DLCS.HydraModel/Image.cs +++ b/src/protagonist/DLCS.HydraModel/Image.cs @@ -195,6 +195,11 @@ public Image(string baseUrl, int customerId, int space, string modelId) [JsonProperty(Order = 130, PropertyName = "textType")] public string? TextType { get; set; } // e.g., METS-ALTO, hOCR, TEI, text/plain etc + [RdfProperty(Description = "Delivery channel specifying how the asset will be available.", + Range = Names.XmlSchema.String, ReadOnly = false, WriteOnly = false)] + [JsonProperty(Order = 140, PropertyName = "deliveryChannels")] + public DeliveryChannel[]? DeliveryChannels { get; set; } + [RdfProperty(Description = "Delivery channel specifying how the asset will be available.", Range = Names.XmlSchema.String, ReadOnly = false, WriteOnly = false)] [JsonProperty(Order = 141, PropertyName = "wcDeliveryChannels")] From f4941e7772ddc359c50771e2786e53f08ec23373 Mon Sep 17 00:00:00 2001 From: griffri Date: Tue, 13 Feb 2024 10:08:49 +0000 Subject: [PATCH 3/4] Remove CustomerID, SpaceId, and ModelId. Change methods to GET, POST and PUT --- .../DLCS.HydraModel/DeliveryChannel.cs | 33 ++----------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/src/protagonist/DLCS.HydraModel/DeliveryChannel.cs b/src/protagonist/DLCS.HydraModel/DeliveryChannel.cs index 45d37e953..d904087f0 100644 --- a/src/protagonist/DLCS.HydraModel/DeliveryChannel.cs +++ b/src/protagonist/DLCS.HydraModel/DeliveryChannel.cs @@ -6,38 +6,9 @@ namespace DLCS.HydraModel; [HydraClass(typeof(DeliveryChannelClass), Description = "A delivery channel represents a way an asset on the DLCS can be served.", - UriTemplate = "/customers/{0}/defaultDeliveryChannels/{1}, /customers/{0}/spaces/{1}/defaultDeliveryChannels/{2}")] + UriTemplate = "")] public class DeliveryChannel : DlcsResource { - public DeliveryChannel() - { - - } - - public DeliveryChannel(string baseUrl, int customerId, string deliveryChannelId, int? spaceId) - { - ModelId = deliveryChannelId; - CustomerId = customerId; - SpaceId = spaceId; - if (spaceId.HasValue) - { - Init(baseUrl, false, customerId, spaceId, deliveryChannelId); - } - else - { - Init(baseUrl, false, customerId, deliveryChannelId); - } - } - - [JsonIgnore] - public int CustomerId { get; set; } - - [JsonIgnore] - public int? SpaceId { get; set; } - - [JsonIgnore] - public string? ModelId { get; set; } - [RdfProperty(Description = "The name of the DLCS delivery channel this is based on.", Range = Names.XmlSchema.String, ReadOnly = false, WriteOnly = false)] [JsonProperty(Order = 11, PropertyName = "channel")] @@ -62,6 +33,6 @@ public override void DefineOperations() { SupportedOperations = CommonOperations.GetStandardResourceOperations( operationId, "Delivery Channel", Id, - "GET", "PUT", "DELETE"); + "GET", "POST", "PUT"); } } \ No newline at end of file From d98c70f041bf7c5a7926533cf5c6ebf310ab5f3d Mon Sep 17 00:00:00 2001 From: griffri Date: Wed, 14 Feb 2024 09:49:13 +0000 Subject: [PATCH 4/4] Add PATCH and DELETE methods --- src/protagonist/DLCS.HydraModel/DeliveryChannel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/protagonist/DLCS.HydraModel/DeliveryChannel.cs b/src/protagonist/DLCS.HydraModel/DeliveryChannel.cs index d904087f0..d119a0c2f 100644 --- a/src/protagonist/DLCS.HydraModel/DeliveryChannel.cs +++ b/src/protagonist/DLCS.HydraModel/DeliveryChannel.cs @@ -33,6 +33,6 @@ public override void DefineOperations() { SupportedOperations = CommonOperations.GetStandardResourceOperations( operationId, "Delivery Channel", Id, - "GET", "POST", "PUT"); + "GET", "POST", "PUT", "PATCH", "DELETE"); } } \ No newline at end of file