Skip to content

Commit 36f11fb

Browse files
committed
Merge branch 'v4/dev' into v9/dev
# Conflicts: # build/NuSpecs/UmbracoDeploy.Contrib.nuspec # build/RunBuild.bat # build/version.txt # src/NuGet.config # src/Umbraco.Deploy.Contrib.Connectors/GridCellValueConnectors/DocTypeGridEditorCellValueConnector.cs # src/Umbraco.Deploy.Contrib.Connectors/Umbraco.Deploy.Contrib.Connectors.csproj # src/Umbraco.Deploy.Contrib/Properties/VersionInfo.cs # src/Umbraco.Deploy.Contrib/ValueConnectors/BlockEditorValueConnector.cs # src/Umbraco.Deploy.Contrib/ValueConnectors/MultiUrlPickerValueConnector.cs # src/Umbraco.Deploy.Contrib/ValueConnectors/NestedContentValueConnector.cs
2 parents c19cc38 + 99e6e7a commit 36f11fb

File tree

6 files changed

+69
-47
lines changed

6 files changed

+69
-47
lines changed

src/Directory.Build.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>9.0.2</Version>
4-
<AssemblyVersion>9.0.2</AssemblyVersion>
5-
<InformationalVersion>9.0.2</InformationalVersion>
6-
<FileVersion>9.0.2</FileVersion>
3+
<Version>9.1.0</Version>
4+
<AssemblyVersion>9.1.0</AssemblyVersion>
5+
<InformationalVersion>9.1.0-alpha001</InformationalVersion>
6+
<FileVersion>9.1.0</FileVersion>
77
<LangVersion Condition="'$(LangVersion)' == ''">9.0</LangVersion>
88
<NeutralLanguage>en-US</NeutralLanguage>
99
<Company>Umbraco</Company>

src/Umbraco.Deploy.Contrib/Properties/VersionInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// </auto-generated>
99
//------------------------------------------------------------------------------
1010

11-
[assembly: System.Reflection.AssemblyInformationalVersion("9.0.2")]
12-
[assembly: System.Reflection.AssemblyVersion("9.0.2")]
11+
[assembly: System.Reflection.AssemblyInformationalVersion("9.1.0-alpha001")]
12+
[assembly: System.Reflection.AssemblyVersion("9.1.0")]
1313

1414

src/Umbraco.Deploy.Contrib/Umbraco.Deploy.Contrib.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88

99
<ItemGroup>
1010
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
11-
<PackageReference Include="Umbraco.Deploy.Core" Version="9.0.0" />
11+
<PackageReference Include="Umbraco.Deploy.Core" Version="9.5.0-preview20220825.102593" />
1212
</ItemGroup>
1313
</Project>

src/Umbraco.Deploy.Contrib/ValueConnectors/BlockEditorValueConnector.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
using Umbraco.Cms.Core.Deploy;
88
using Umbraco.Cms.Core.Models;
99
using Umbraco.Cms.Core.Services;
10+
using Umbraco.Deploy.Core;
11+
using Umbraco.Deploy.Core.Connectors;
12+
using Umbraco.Deploy.Core.Connectors.ValueConnectors;
1013
using Umbraco.Deploy.Core.Connectors.ValueConnectors.Services;
1114
using Umbraco.Extensions;
1215

@@ -15,13 +18,17 @@ namespace Umbraco.Deploy.Contrib.ValueConnectors
1518
/// <summary>
1619
/// A Deploy connector for BlockEditor based property editors (ie. BlockList)
1720
/// </summary>
18-
public abstract class BlockEditorValueConnector : IValueConnector
21+
public abstract class BlockEditorValueConnector : ValueConnectorBase
1922
{
2023
private readonly IContentTypeService _contentTypeService;
2124
private readonly Lazy<ValueConnectorCollection> _valueConnectorsLazy;
2225
private readonly ILogger<BlockEditorValueConnector> _logger;
2326

24-
public virtual IEnumerable<string> PropertyEditorAliases => new[] { "Umbraco.BlockEditor" };
27+
/// <inheritdoc />
28+
public override IEnumerable<string> PropertyEditorAliases { get; } = new[]
29+
{
30+
"Umbraco.BlockEditor"
31+
};
2532

2633
// cannot inject ValueConnectorCollection directly as it would cause a circular (recursive) dependency,
2734
// so we have to inject it lazily and use the lazy value when actually needing it
@@ -37,7 +44,7 @@ public BlockEditorValueConnector(IContentTypeService contentTypeService, Lazy<Va
3744
_logger = logger;
3845
}
3946

40-
public virtual string ToArtifact(object value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies)
47+
public override string ToArtifact(object value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache)
4148
{
4249
_logger.LogDebug("Converting {PropertyType} to artifact.", propertyType.Alias);
4350
var svalue = value as string;
@@ -78,7 +85,8 @@ public virtual string ToArtifact(object value, IPropertyType propertyType, IColl
7885
{
7986
if (!Guid.TryParse(a, out var keyAsGuid))
8087
throw new InvalidOperationException($"Could not parse ContentTypeKey as GUID {keyAsGuid}.");
81-
return _contentTypeService.Get(keyAsGuid);
88+
89+
return contextCache.GetContentTypeByKey(_contentTypeService, keyAsGuid);
8290
});
8391

8492
//Ensure all of these content types are found
@@ -116,7 +124,7 @@ public virtual string ToArtifact(object value, IPropertyType propertyType, IColl
116124

117125
// pass the value, property type and the dependencies collection to the connector to get a "artifact" value
118126
var innerValue = block.PropertyValues[key];
119-
object parsedValue = propertyValueConnector.ToArtifact(innerValue, innerPropertyType, dependencies);
127+
object parsedValue = propertyValueConnector.ToArtifact(innerValue, innerPropertyType, dependencies, contextCache);
120128

121129
_logger.LogDebug("Mapped {Key} value '{PropertyValue}' to '{ParsedValue}' using {PropertyValueConnectorType} for {PropertyType}.", key, block.PropertyValues[key], parsedValue, propertyValueConnector.GetType(), innerPropertyType.Alias);
122130

@@ -132,7 +140,7 @@ public virtual string ToArtifact(object value, IPropertyType propertyType, IColl
132140
return (string) value;
133141
}
134142

135-
public virtual object FromArtifact(string value, IPropertyType propertyType, object currentValue)
143+
public override object FromArtifact(string value, IPropertyType propertyType, object currentValue, IContextCache contextCache)
136144
{
137145
_logger.LogDebug("Converting {PropertyType} from artifact.", propertyType.Alias);
138146
if (string.IsNullOrWhiteSpace(value))
@@ -156,7 +164,8 @@ public virtual object FromArtifact(string value, IPropertyType propertyType, obj
156164
{
157165
if (!Guid.TryParse(a, out var keyAsGuid))
158166
throw new InvalidOperationException($"Could not parse ContentTypeKey as GUID {keyAsGuid}.");
159-
return _contentTypeService.Get(keyAsGuid);
167+
168+
return contextCache.GetContentTypeByKey(_contentTypeService, keyAsGuid);
160169
});
161170

162171
//Ensure all of these content types are found
@@ -190,7 +199,7 @@ public virtual object FromArtifact(string value, IPropertyType propertyType, obj
190199
if (innerValue != null)
191200
{
192201
// pass the artifact value and property type to the connector to get a real value from the artifact
193-
var convertedValue = propertyValueConnector.FromArtifact(innerValue.ToString(), innerPropertyType, null);
202+
var convertedValue = propertyValueConnector.FromArtifact(innerValue.ToString(), innerPropertyType, null, contextCache);
194203

195204
if (convertedValue == null)
196205
{

src/Umbraco.Deploy.Contrib/ValueConnectors/MultiUrlPickerValueConnector.cs

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text.RegularExpressions;
4-
using Microsoft.Extensions.Logging;
1+
using Microsoft.Extensions.Logging;
52
using Newtonsoft.Json;
63
using Newtonsoft.Json.Linq;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Text.RegularExpressions;
77
using Umbraco.Cms.Core;
88
using Umbraco.Cms.Core.Deploy;
99
using Umbraco.Cms.Core.Models;
1010
using Umbraco.Cms.Core.PropertyEditors;
1111
using Umbraco.Cms.Core.Services;
12+
using Umbraco.Deploy.Core;
13+
using Umbraco.Deploy.Core.Connectors.ValueConnectors;
1214
using Umbraco.Extensions;
1315

1416
namespace Umbraco.Deploy.Contrib.ValueConnectors
1517
{
16-
public class MultiUrlPickerValueConnector : IValueConnector
18+
public class MultiUrlPickerValueConnector : ValueConnectorBase
1719
{
1820
private readonly IEntityService _entityService;
1921
private readonly IMediaService _mediaService;
@@ -23,6 +25,12 @@ public class MultiUrlPickerValueConnector : IValueConnector
2325
// Used to fetch the udi from a umb://-based url
2426
private static readonly Regex MediaUdiSrcRegex = new Regex(@"(?<udi>umb://media/[A-z0-9]+)", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
2527

28+
/// <inheritdoc />
29+
public override IEnumerable<string> PropertyEditorAliases { get; } = new[]
30+
{
31+
"Umbraco.MultiUrlPicker"
32+
};
33+
2634
/// <summary>
2735
/// Initializes a new instance of the <see cref="MultiUrlPickerValueConnector"/> class.
2836
/// Source found here: https://github.com/rasmusjp/umbraco-multi-url-picker
@@ -57,7 +65,7 @@ public MultiUrlPickerValueConnector(
5765
_mediaUrlGenerators = mediaUrlGenerators;
5866
}
5967

60-
public string ToArtifact(object value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies)
68+
public sealed override string ToArtifact(object value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache)
6169
{
6270
var svalue = value as string;
6371
if (string.IsNullOrWhiteSpace(svalue))
@@ -75,11 +83,9 @@ public string ToArtifact(object value, IPropertyType propertyType, ICollection<A
7583
foreach (var link in links)
7684
{
7785
var isMedia = link["isMedia"] != null;
78-
int intId;
79-
string url;
80-
GuidUdi guidUdi;
86+
8187
// Only do processing if the Id is set on the element. OR if the url is set and its a media item
82-
if (TryParseJTokenAttr(link, "id", out intId))
88+
if (TryParseJTokenAttr(link, "id", out int intId))
8389
{
8490
// Checks weather we are resolving a media item or a document
8591
var objectTypeId = isMedia
@@ -92,15 +98,16 @@ public string ToArtifact(object value, IPropertyType propertyType, ICollection<A
9298
continue;
9399

94100
var udi = new GuidUdi(entityType, guidAttempt.Result);
101+
95102
// Add the artifact dependency
96103
dependencies.Add(new ArtifactDependency(udi, false, ArtifactDependencyMode.Exist));
97104

98105
// Set the Id attribute to the udi
99106
link["id"] = udi.ToString();
100107
}
101-
else if (TryParseJTokenAttr(link, "udi", out guidUdi))
108+
else if (TryParseJTokenAttr(link, "udi", out GuidUdi guidUdi))
102109
{
103-
var entityExists = _entityService.Exists(guidUdi.Guid);
110+
var entityExists = contextCache.EntityExists(_entityService, guidUdi.Guid);
104111
if (!entityExists)
105112
{
106113
continue;
@@ -109,7 +116,7 @@ public string ToArtifact(object value, IPropertyType propertyType, ICollection<A
109116
// Add the artifact dependency
110117
dependencies.Add(new ArtifactDependency(guidUdi, false, ArtifactDependencyMode.Exist));
111118
}
112-
else if (isMedia && TryParseJTokenAttr(link, "url", out url))
119+
else if (isMedia && TryParseJTokenAttr(link, "url", out string url))
113120
{
114121
// This state can happen due to an issue in RJP.MultiUrlPicker(or our linkPicker in RTE which it relies on),
115122
// where you edit a media link, and just hit "Select".
@@ -150,10 +157,11 @@ public string ToArtifact(object value, IPropertyType propertyType, ICollection<A
150157
: UmbracoObjectTypes.Document;
151158
var entityType = isMedia ? Constants.UdiEntityType.Media : Constants.UdiEntityType.Document;
152159

153-
var guidAttempt = _entityService.GetKey(intId, objectTypeId);
160+
var guidAttempt = contextCache.GetEntityKeyById(_entityService, intId, objectTypeId);
154161
if (guidAttempt.Success)
155162
{
156163
var udi = new GuidUdi(entityType, guidAttempt.Result);
164+
157165
// Add the artifact dependency
158166
dependencies.Add(new ArtifactDependency(udi, false, ArtifactDependencyMode.Exist));
159167

@@ -163,8 +171,7 @@ public string ToArtifact(object value, IPropertyType propertyType, ICollection<A
163171
}
164172
else if (TryParseJTokenAttr(link, "udi", out guidUdi))
165173
{
166-
var entity = _entityService.Get(guidUdi.Guid, UdiEntityTypeHelper.ToUmbracoObjectType(guidUdi.EntityType));
167-
if (entity != null)
174+
if (contextCache.EntityExists(_entityService, guidUdi.Guid))
168175
{
169176
// Add the artifact dependency
170177
dependencies.Add(new ArtifactDependency(guidUdi, false, ArtifactDependencyMode.Exist));
@@ -194,7 +201,7 @@ public string ToArtifact(object value, IPropertyType propertyType, ICollection<A
194201
return string.Empty;
195202
}
196203

197-
public object FromArtifact(string value, IPropertyType propertyType, object currentValue)
204+
public sealed override object FromArtifact(string value, IPropertyType propertyType, object currentValue, IContextCache contextCache)
198205
{
199206
if (string.IsNullOrWhiteSpace(value))
200207
{
@@ -224,7 +231,7 @@ public object FromArtifact(string value, IPropertyType propertyType, object curr
224231
// Get the Id corresponding to the Guid
225232
// it *should* succeed when deploying, due to dependencies management
226233
// nevertheless, assume it can fail, and then create an invalid localLink
227-
var idAttempt = _entityService.GetId(udi.Guid, nodeObjectType);
234+
var idAttempt = contextCache.GetEntityIdByKey(_entityService, udi.Guid, nodeObjectType);
228235
if (idAttempt)
229236
link["id"] = idAttempt.Success ? idAttempt.Result : 0;
230237
}
@@ -269,7 +276,7 @@ public object FromArtifact(string value, IPropertyType propertyType, object curr
269276
// Get the Id corresponding to the Guid
270277
// it *should* succeed when deploying, due to dependencies management
271278
// nevertheless, assume it can fail, and then create an invalid localLink
272-
var idAttempt = _entityService.GetId(udi.Guid, nodeObjectType);
279+
var idAttempt = contextCache.GetEntityIdByKey(_entityService, udi.Guid, nodeObjectType);
273280
if (idAttempt)
274281
link["id"] = idAttempt.Success ? idAttempt.Result : 0;
275282
}
@@ -301,9 +308,6 @@ public object FromArtifact(string value, IPropertyType propertyType, object curr
301308
return value;
302309
}
303310

304-
/// <inheritdoc/>
305-
public virtual IEnumerable<string> PropertyEditorAliases => new[] { "RJP.MultiUrlPicker", "Umbraco.MultiUrlPicker" };
306-
307311
private bool TryParseJTokenAttr(JToken link, string attrName, out int attrValue)
308312
{
309313
if (link[attrName] != null)

src/Umbraco.Deploy.Contrib/ValueConnectors/NestedContentValueConnector.cs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
using Umbraco.Cms.Core.Deploy;
88
using Umbraco.Cms.Core.Models;
99
using Umbraco.Cms.Core.Services;
10+
using Umbraco.Deploy.Core;
11+
using Umbraco.Deploy.Core.Connectors;
12+
using Umbraco.Deploy.Core.Connectors.ValueConnectors;
1013
using Umbraco.Deploy.Core.Connectors.ValueConnectors.Services;
1114
using Umbraco.Extensions;
1215

@@ -15,15 +18,21 @@ namespace Umbraco.Deploy.Contrib.ValueConnectors
1518
/// <summary>
1619
/// A Deploy connector for the NestedContent property editor
1720
/// </summary>
18-
public class NestedContentValueConnector : IValueConnector
21+
public class NestedContentValueConnector : ValueConnectorBase
1922
{
2023
private readonly IContentTypeService _contentTypeService;
2124
private readonly Lazy<ValueConnectorCollection> _valueConnectorsLazy;
2225
private readonly ILogger<NestedContentValueConnector> _logger;
2326

24-
// Our.Umbraco.NestedContent is the original NestedContent package
25-
// Umbraco.NestedContent is Core NestedContent (introduced in v7.7)
26-
public virtual IEnumerable<string> PropertyEditorAliases => new[] { "Our.Umbraco.NestedContent", "Umbraco.NestedContent" };
27+
/// <inheritdoc />
28+
/// <remarks>
29+
/// Our.Umbraco.NestedContent is the original NestedContent package
30+
/// Umbraco.NestedContent is Core NestedContent (introduced in v7.7)
31+
/// </remarks>
32+
public override IEnumerable<string> PropertyEditorAliases { get; } = new[]
33+
{
34+
"Umbraco.NestedContent"
35+
};
2736

2837
// cannot inject ValueConnectorCollection as it creates a circular (recursive) dependency,
2938
// so we have to inject it lazily and use the lazy value when actually needing it
@@ -39,7 +48,7 @@ public NestedContentValueConnector(IContentTypeService contentTypeService, Lazy<
3948
_logger = logger;
4049
}
4150

42-
public string ToArtifact(object value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies)
51+
public sealed override string ToArtifact(object value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache)
4352
{
4453
_logger.LogDebug("Converting {PropertyType} to artifact.", propertyType.Alias);
4554
var svalue = value as string;
@@ -74,7 +83,7 @@ public string ToArtifact(object value, IPropertyType propertyType, ICollection<A
7483

7584
var allContentTypes = nestedContent.Select(x => x.ContentTypeAlias)
7685
.Distinct()
77-
.ToDictionary(a => a, a => _contentTypeService.Get(a));
86+
.ToDictionary(a => a, a => contextCache.GetContentTypeByAlias(_contentTypeService, a));
7887

7988
//Ensure all of these content types are found
8089
if (allContentTypes.Values.Any(contentType => contentType == null))
@@ -119,7 +128,7 @@ public string ToArtifact(object value, IPropertyType propertyType, ICollection<A
119128
object preparedValue = innerValue is JToken
120129
? innerValue?.ToString()
121130
: innerValue;
122-
object parsedValue = propertyValueConnector.ToArtifact(preparedValue, innerPropertyType, dependencies);
131+
object parsedValue = propertyValueConnector.ToArtifact(preparedValue, innerPropertyType, dependencies, contextCache);
123132

124133
// getting Map image value umb://media/43e7401fb3cd48ceaa421df511ec703c to (nothing) - why?!
125134
_logger.LogDebug("Mapped {Key} value '{PropertyValue}' to '{ParsedValue}' using {PropertyValueConnectorType} for {PropertyType}.", key, row.PropertyValues[key], parsedValue, propertyValueConnector.GetType(), innerPropertyType.Alias);
@@ -135,7 +144,7 @@ public string ToArtifact(object value, IPropertyType propertyType, ICollection<A
135144
return (string)value;
136145
}
137146

138-
public object FromArtifact(string value, IPropertyType propertyType, object currentValue)
147+
public sealed override object FromArtifact(string value, IPropertyType propertyType, object currentValue, IContextCache contextCache)
139148
{
140149
_logger.LogDebug("Converting {PropertyType} from artifact.", propertyType.Alias);
141150
if (string.IsNullOrWhiteSpace(value))
@@ -160,7 +169,7 @@ public object FromArtifact(string value, IPropertyType propertyType, object curr
160169

161170
var allContentTypes = nestedContent.Select(x => x.ContentTypeAlias)
162171
.Distinct()
163-
.ToDictionary(a => a, a => _contentTypeService.Get(a));
172+
.ToDictionary(a => a, a => contextCache.GetContentTypeByAlias(_contentTypeService, a));
164173

165174
//Ensure all of these content types are found
166175
if (allContentTypes.Values.Any(contentType => contentType == null))
@@ -196,7 +205,7 @@ public object FromArtifact(string value, IPropertyType propertyType, object curr
196205
if (innerValue != null)
197206
{
198207
// pass the artifact value and property type to the connector to get a real value from the artifact
199-
var convertedValue = propertyValueConnector.FromArtifact(innerValue.ToString(), innerPropertyType, null);
208+
var convertedValue = propertyValueConnector.FromArtifact(innerValue.ToString(), innerPropertyType, null, contextCache);
200209

201210
if (convertedValue == null)
202211
{

0 commit comments

Comments
 (0)