Netcore: Migration of Model classes from Umbraco.Infrastructure to Core (#9404)

* Migrating more model, mapping and tree classes

* Migrating files from Mapping dir without Newtonsoft dependency

* Migrating files from PublishedContent and Editors dirs without Newtonsoft dependency + some more of the same kind

* Migrating DataType class without the usage of Newtonsoft.Json and making the corresponding changes to all classes affected

* Combining 3 ContentExtensions files into 1

* Refactoring from migrating ContentExtensions

* Migrating more classes

* Migrating ContentRepositoryExtensions - combining it with existing file in Umbraco.Core

* removing Newtonsoft json dependency & migrating file. Adding partial migration of ConfigurationEditor, so PropertyTagsExtensions can be migrated

* Migrating ContentTagsExtensions, and refactoring from changes in PropertyTagsExtensions

* Changes that should be reverted once ConfigurationEditor class is fully migrated

* VS couldn't find Composing, so build was failing. Removing the using solves the problem

* Handling a single case for deserializing a subset of an input

* Small changes and added tests to JsonNetSerializer

Signed-off-by: Bjarke Berg <mail@bergmania.dk>

* Migrated ConfigurationEditor

Signed-off-by: Bjarke Berg <mail@bergmania.dk>

Co-authored-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
Elitsa Marinovska
2020-11-17 20:27:10 +01:00
committed by GitHub
parent d498c1a2cd
commit dd5f400cf3
116 changed files with 1098 additions and 897 deletions

View File

@@ -21,6 +21,7 @@ using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Querying;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Security;
using Umbraco.Core.Serialization;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
using Umbraco.Web.Actions;
@@ -98,8 +99,9 @@ namespace Umbraco.Web.BackOffice.Controllers
INotificationService notificationService,
ActionCollection actionCollection,
IMemberGroupService memberGroupService,
ISqlContext sqlContext)
: base(cultureDictionary, loggerFactory, shortStringHelper, eventMessages, localizedTextService)
ISqlContext sqlContext,
IJsonSerializer serializer)
: base(cultureDictionary, loggerFactory, shortStringHelper, eventMessages, localizedTextService, serializer)
{
_propertyEditors = propertyEditors;
_contentService = contentService;

View File

@@ -13,6 +13,7 @@ using Umbraco.Core.Mapping;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Editors;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Serialization;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
using Umbraco.Extensions;
@@ -34,13 +35,15 @@ namespace Umbraco.Web.BackOffice.Controllers
protected IEventMessagesFactory EventMessages { get; }
protected ILocalizedTextService LocalizedTextService { get; }
private readonly ILogger<ContentControllerBase> _logger;
private readonly IJsonSerializer _serializer;
protected ContentControllerBase(
ICultureDictionary cultureDictionary,
ILoggerFactory loggerFactory,
IShortStringHelper shortStringHelper,
IEventMessagesFactory eventMessages,
ILocalizedTextService localizedTextService)
ILocalizedTextService localizedTextService,
IJsonSerializer serializer)
{
CultureDictionary = cultureDictionary;
LoggerFactory = loggerFactory;
@@ -48,6 +51,7 @@ namespace Umbraco.Web.BackOffice.Controllers
ShortStringHelper = shortStringHelper;
EventMessages = eventMessages;
LocalizedTextService = localizedTextService;
_serializer = serializer;
}
protected NotFoundObjectResult HandleContentNotFound(object id, bool throwException = true)
@@ -117,7 +121,7 @@ namespace Umbraco.Web.BackOffice.Controllers
var tagConfiguration = ConfigurationEditor.ConfigurationAs<TagConfiguration>(propertyDto.DataType.Configuration);
if (tagConfiguration.Delimiter == default) tagConfiguration.Delimiter = tagAttribute.Delimiter;
var tagCulture = property.PropertyType.VariesByCulture() ? culture : null;
property.SetTagsValue(value, tagConfiguration, tagCulture);
property.SetTagsValue(_serializer, value, tagConfiguration, tagCulture);
}
else
savePropertyValue(contentItem, property, value);

View File

@@ -35,6 +35,7 @@ using Umbraco.Web.Security;
using ContentType = Umbraco.Core.Models.ContentType;
using Umbraco.Core.Configuration.Models;
using Microsoft.Extensions.Options;
using Umbraco.Core.Serialization;
namespace Umbraco.Web.BackOffice.Controllers
{
@@ -70,6 +71,7 @@ namespace Umbraco.Web.BackOffice.Controllers
private readonly IMacroService _macroService;
private readonly IEntityService _entityService;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IConfigurationEditorJsonSerializer _jsonSerializer;
public ContentTypeController(
ICultureDictionary cultureDictionary,
@@ -95,7 +97,8 @@ namespace Umbraco.Web.BackOffice.Controllers
IMacroService macroService,
IEntityService entityService,
IHostingEnvironment hostingEnvironment,
EditorValidatorCollection editorValidatorCollection)
EditorValidatorCollection editorValidatorCollection,
IConfigurationEditorJsonSerializer jsonSerializer)
: base(cultureDictionary,
editorValidatorCollection,
contentTypeService,
@@ -124,6 +127,7 @@ namespace Umbraco.Web.BackOffice.Controllers
_macroService = macroService;
_entityService = entityService;
_hostingEnvironment = hostingEnvironment;
_jsonSerializer = jsonSerializer;
}
public int GetCount()
@@ -621,7 +625,7 @@ namespace Umbraco.Web.BackOffice.Controllers
}
var dataInstaller = new PackageDataInstallation(_loggerFactory.CreateLogger<PackageDataInstallation>(), _loggerFactory, _fileService, _macroService, _LocalizationService,
_dataTypeService, _entityService, _contentTypeService, _contentService, _propertyEditors, _scopeProvider, _shortStringHelper, Options.Create(_globalSettings), _localizedTextService);
_dataTypeService, _entityService, _contentTypeService, _contentService, _propertyEditors, _scopeProvider, _shortStringHelper, Options.Create(_globalSettings), _localizedTextService, _jsonSerializer);
var xd = new XmlDocument {XmlResolver = null};
xd.Load(filePath);

View File

@@ -12,6 +12,7 @@ using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Mapping;
using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Serialization;
using Umbraco.Core.Services;
using Umbraco.Web.BackOffice.Filters;
using Umbraco.Web.Common.Attributes;
@@ -43,6 +44,7 @@ namespace Umbraco.Web.BackOffice.Controllers
private readonly IMemberTypeService _memberTypeService;
private readonly ILocalizedTextService _localizedTextService;
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
private readonly IConfigurationEditorJsonSerializer _serializer;
public DataTypeController(
PropertyEditorCollection propertyEditors,
@@ -54,7 +56,8 @@ namespace Umbraco.Web.BackOffice.Controllers
IMediaTypeService mediaTypeService,
IMemberTypeService memberTypeService,
ILocalizedTextService localizedTextService,
IUmbracoContextAccessor umbracoContextAccessor)
IUmbracoContextAccessor umbracoContextAccessor,
IConfigurationEditorJsonSerializer serializer)
{
_propertyEditors = propertyEditors ?? throw new ArgumentNullException(nameof(propertyEditors));
_dataTypeService = dataTypeService ?? throw new ArgumentNullException(nameof(dataTypeService));
@@ -66,6 +69,7 @@ namespace Umbraco.Web.BackOffice.Controllers
_memberTypeService = memberTypeService ?? throw new ArgumentNullException(nameof(memberTypeService));
_localizedTextService = localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService));
_umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor));
_serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
}
/// <summary>
@@ -155,7 +159,7 @@ namespace Umbraco.Web.BackOffice.Controllers
{
// cannot create an "empty" data type, so use something by default.
var editor = _propertyEditors[Constants.PropertyEditors.Aliases.Label];
var dt = new DataType(editor, parentId);
var dt = new DataType(editor, _serializer, parentId);
return _umbracoMapper.Map<IDataType, DataTypeDisplay>(dt);
}
@@ -188,7 +192,7 @@ namespace Umbraco.Web.BackOffice.Controllers
if (dt == null)
{
var editor = _propertyEditors[Constants.PropertyEditors.Aliases.ListView];
dt = new DataType(editor) { Name = Constants.Conventions.DataTypes.ListViewPrefix + contentTypeAlias };
dt = new DataType(editor, _serializer) { Name = Constants.Conventions.DataTypes.ListViewPrefix + contentTypeAlias };
_dataTypeService.Save(dt);
}

View File

@@ -28,6 +28,7 @@ using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Querying;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Security;
using Umbraco.Core.Serialization;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
using Umbraco.Extensions;
@@ -63,6 +64,7 @@ namespace Umbraco.Web.BackOffice.Controllers
private readonly IContentTypeBaseServiceProvider _contentTypeBaseServiceProvider;
private readonly IRelationService _relationService;
private readonly IImageUrlGenerator _imageUrlGenerator;
private readonly IJsonSerializer _serializer;
private readonly ILogger<MediaController> _logger;
public MediaController(
@@ -84,8 +86,9 @@ namespace Umbraco.Web.BackOffice.Controllers
PropertyEditorCollection propertyEditors,
IMediaFileSystem mediaFileSystem,
IHostingEnvironment hostingEnvironment,
IImageUrlGenerator imageUrlGenerator)
: base(cultureDictionary, loggerFactory, shortStringHelper, eventMessages, localizedTextService)
IImageUrlGenerator imageUrlGenerator,
IJsonSerializer serializer)
: base(cultureDictionary, loggerFactory, shortStringHelper, eventMessages, localizedTextService, serializer)
{
_shortStringHelper = shortStringHelper;
_contentSettings = contentSettings.Value;
@@ -104,6 +107,7 @@ namespace Umbraco.Web.BackOffice.Controllers
_hostingEnvironment = hostingEnvironment;
_logger = loggerFactory.CreateLogger<MediaController>();
_imageUrlGenerator = imageUrlGenerator;
_serializer = serializer;
}
/// <summary>
@@ -764,7 +768,7 @@ namespace Umbraco.Web.BackOffice.Controllers
await using (var stream = formFile.OpenReadStream())
{
f.SetValue(_mediaFileSystem,_shortStringHelper, _contentTypeBaseServiceProvider, Constants.Conventions.Media.File,fileName, stream);
f.SetValue(_mediaFileSystem,_shortStringHelper, _contentTypeBaseServiceProvider, _serializer, Constants.Conventions.Media.File,fileName, stream);
}
@@ -774,7 +778,6 @@ namespace Umbraco.Web.BackOffice.Controllers
AddCancelMessage(tempFiles,
message: _localizedTextService.Localize("speechBubbles/operationCancelledText") + " -- " + mediaItemName);
}
}
else
{

View File

@@ -71,7 +71,7 @@ namespace Umbraco.Web.BackOffice.Controllers
IDataTypeService dataTypeService,
IBackofficeSecurityAccessor backofficeSecurityAccessor,
IJsonSerializer jsonSerializer)
: base(cultureDictionary, loggerFactory, shortStringHelper, eventMessages, localizedTextService)
: base(cultureDictionary, loggerFactory, shortStringHelper, eventMessages, localizedTextService, jsonSerializer)
{
_passwordConfig = passwordConfig.Value;
_propertyEditors = propertyEditors;