Beispiel #1
0
 public DataTypeMapDefinition(PropertyEditorCollection propertyEditors, ILogger <DataTypeMapDefinition> logger, IOptions <ContentSettings> contentSettings, IConfigurationEditorJsonSerializer serializer)
 {
     _propertyEditors = propertyEditors;
     _logger          = logger;
     _contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings));
     _serializer      = serializer;
 }
 public MergeDateAndDateTimePropertyEditor(IMigrationContext context, IIOHelper ioHelper, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer, IEditorConfigurationParser editorConfigurationParser)
     : base(context)
 {
     _ioHelper = ioHelper;
     _configurationEditorJsonSerializer = configurationEditorJsonSerializer;
     _editorConfigurationParser         = editorConfigurationParser;
 }
Beispiel #3
0
 public DataTypeController(
     PropertyEditorCollection propertyEditors,
     IDataTypeService dataTypeService,
     IOptionsSnapshot <ContentSettings> contentSettings,
     IUmbracoMapper umbracoMapper,
     PropertyEditorCollection propertyEditorCollection,
     IContentTypeService contentTypeService,
     IMediaTypeService mediaTypeService,
     IMemberTypeService memberTypeService,
     ILocalizedTextService localizedTextService,
     IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
     IConfigurationEditorJsonSerializer serializer)
 {
     _propertyEditors            = propertyEditors ?? throw new ArgumentNullException(nameof(propertyEditors));
     _dataTypeService            = dataTypeService ?? throw new ArgumentNullException(nameof(dataTypeService));
     _contentSettings            = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings));
     _umbracoMapper              = umbracoMapper ?? throw new ArgumentNullException(nameof(umbracoMapper));
     _propertyEditorCollection   = propertyEditorCollection ?? throw new ArgumentNullException(nameof(propertyEditorCollection));
     _contentTypeService         = contentTypeService ?? throw new ArgumentNullException(nameof(contentTypeService));
     _mediaTypeService           = mediaTypeService ?? throw new ArgumentNullException(nameof(mediaTypeService));
     _memberTypeService          = memberTypeService ?? throw new ArgumentNullException(nameof(memberTypeService));
     _localizedTextService       = localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService));
     _backOfficeSecurityAccessor = backOfficeSecurityAccessor ?? throw new ArgumentNullException(nameof(backOfficeSecurityAccessor));
     _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
 }
 public CreateVendrCheckoutDataTypesTask(IDataTypeService dataTypeService, PropertyEditorCollection propertyEditors,
                                         IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
 {
     _dataTypeService = dataTypeService;
     _propertyEditors = propertyEditors;
     _configurationEditorJsonSerializer = configurationEditorJsonSerializer;
 }
Beispiel #5
0
 public DataTypeController(
     PropertyEditorCollection propertyEditors,
     IDataTypeService dataTypeService,
     IOptionsSnapshot <ContentSettings> contentSettings,
     IUmbracoMapper umbracoMapper,
     PropertyEditorCollection propertyEditorCollection,
     IContentTypeService contentTypeService,
     IMediaTypeService mediaTypeService,
     IMemberTypeService memberTypeService,
     ILocalizedTextService localizedTextService,
     IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
     IConfigurationEditorJsonSerializer serializer)
     : this(
         propertyEditors,
         dataTypeService,
         contentSettings,
         umbracoMapper,
         propertyEditorCollection,
         contentTypeService,
         mediaTypeService,
         memberTypeService,
         localizedTextService,
         backOfficeSecurityAccessor,
         serializer,
         StaticServiceProvider.Instance.GetRequiredService <IDataTypeUsageService>())
 {
 }
 public RadioAndCheckboxPropertyEditorsMigration(
     IMigrationContext context,
     IIOHelper ioHelper,
     IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
     : this(context, ioHelper, configurationEditorJsonSerializer, StaticServiceProvider.Instance.GetRequiredService <IEditorConfigurationParser>())
 {
 }
Beispiel #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataType"/> class.
        /// </summary>
        public DataType(IDataEditor?editor, IConfigurationEditorJsonSerializer serializer, int parentId = -1)
        {
            _editor     = editor ?? throw new ArgumentNullException(nameof(editor));
            _serializer = serializer ?? throw new ArgumentNullException(nameof(editor));
            ParentId    = parentId;

            // set a default configuration
            Configuration = _editor.GetConfigurationEditor().DefaultConfigurationObject;
        }
 public RadioAndCheckboxPropertyEditorsMigration(
     IMigrationContext context,
     IIOHelper ioHelper,
     IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
     : base(context)
 {
     _ioHelper = ioHelper;
     _configurationEditorJsonSerializer = configurationEditorJsonSerializer;
 }
 public DropDownPropertyEditorsMigration(
     IMigrationContext context,
     IIOHelper ioHelper,
     IConfigurationEditorJsonSerializer configurationEditorJsonSerializer,
     IEditorConfigurationParser editorConfigurationParser)
     : base(context)
 {
     _ioHelper = ioHelper;
     _configurationEditorJsonSerializer = configurationEditorJsonSerializer;
     _editorConfigurationParser         = editorConfigurationParser;
 }
 public DataTypeMigration(IMigrationContext context,
                          PreValueMigratorCollection preValueMigrators,
                          PropertyEditorCollection propertyEditors,
                          ILogger <DataTypeMigration> logger,
                          IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
     : base(context)
 {
     _preValueMigrators = preValueMigrators;
     _propertyEditors   = propertyEditors;
     _logger            = logger;
     _configurationEditorJsonSerializer = configurationEditorJsonSerializer;
 }
Beispiel #11
0
    public static DataTypeDto BuildDto(IDataType entity, IConfigurationEditorJsonSerializer serializer)
    {
        var dataTypeDto = new DataTypeDto
        {
            EditorAlias   = entity.EditorAlias,
            NodeId        = entity.Id,
            DbType        = entity.DatabaseType.ToString(),
            Configuration = ConfigurationEditor.ToDatabase(entity.Configuration, serializer),
            NodeDto       = BuildNodeDto(entity),
        };

        return(dataTypeDto);
    }
Beispiel #12
0
 public DataTypeRepository(
     IScopeAccessor scopeAccessor,
     AppCaches cache,
     PropertyEditorCollection editors,
     ILogger <DataTypeRepository> logger,
     ILoggerFactory loggerFactory,
     IConfigurationEditorJsonSerializer serializer)
     : base(scopeAccessor, cache, logger)
 {
     _editors        = editors;
     _serializer     = serializer;
     _dataTypeLogger = loggerFactory.CreateLogger <IDataType>();
 }
Beispiel #13
0
 public DataTypeSerializer(IEntityService entityService, ILogger <DataTypeSerializer> logger,
                           IDataTypeService dataTypeService,
                           DataEditorCollection dataEditors,
                           ConfigurationSerializerCollection configurationSerializers,
                           PropertyEditorCollection propertyEditors,
                           IConfigurationEditorJsonSerializer jsonSerializer)
     : base(entityService, logger, UmbracoObjectTypes.DataTypeContainer)
 {
     this.dataTypeService          = dataTypeService;
     this.dataEditors              = dataEditors;
     this.configurationSerializers = configurationSerializers;
     this.propertyEditors          = propertyEditors;
     this.jsonSerializer           = jsonSerializer;
 }
 /// <inheritdoc />
 public override object FromDatabase(string configuration, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(configuration))
         {
             return(new TConfiguration());
         }
         return(configurationEditorJsonSerializer.Deserialize <TConfiguration>(configuration));
     }
     catch (Exception e)
     {
         throw new InvalidOperationException($"Failed to parse configuration \"{configuration}\" as \"{typeof(TConfiguration).Name}\" (see inner exception).", e);
     }
 }
Beispiel #15
0
 public EntityXmlSerializer(
     IContentService contentService,
     IMediaService mediaService,
     IDataTypeService dataTypeService,
     IUserService userService,
     ILocalizationService localizationService,
     IContentTypeService contentTypeService,
     UrlSegmentProviderCollection urlSegmentProviders,
     IShortStringHelper shortStringHelper,
     PropertyEditorCollection propertyEditors,
     IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
 {
     _contentTypeService  = contentTypeService;
     _mediaService        = mediaService;
     _contentService      = contentService;
     _dataTypeService     = dataTypeService;
     _userService         = userService;
     _localizationService = localizationService;
     _urlSegmentProviders = urlSegmentProviders;
     _shortStringHelper   = shortStringHelper;
     _propertyEditors     = propertyEditors;
     _configurationEditorJsonSerializer = configurationEditorJsonSerializer;
 }
Beispiel #16
0
    public static IDataType BuildEntity(DataTypeDto dto, PropertyEditorCollection editors, ILogger <IDataType> logger, IConfigurationEditorJsonSerializer serializer)
    {
        // Check we have an editor for the data type.
        if (!editors.TryGet(dto.EditorAlias, out IDataEditor? editor))
        {
            logger.LogWarning(
                "Could not find an editor with alias {EditorAlias}, treating as Label. " + "The site may fail to boot and/or load data types and run.", dto.EditorAlias);

            // Create as special type, which downstream can be handled by converting to a LabelPropertyEditor to make clear
            // the situation to the user.
            editor = new MissingPropertyEditor();
        }

        var dataType = new DataType(editor, serializer);

        try
        {
            dataType.DisableChangeTracking();

            dataType.CreateDate   = dto.NodeDto.CreateDate;
            dataType.DatabaseType = dto.DbType.EnumParse <ValueStorageType>(true);
            dataType.Id           = dto.NodeId;
            dataType.Key          = dto.NodeDto.UniqueId;
            dataType.Level        = dto.NodeDto.Level;
            dataType.UpdateDate   = dto.NodeDto.CreateDate;
            dataType.Name         = dto.NodeDto.Text;
            dataType.ParentId     = dto.NodeDto.ParentId;
            dataType.Path         = dto.NodeDto.Path;
            dataType.SortOrder    = dto.NodeDto.SortOrder;
            dataType.Trashed      = dto.NodeDto.Trashed;
            dataType.CreatorId    = dto.NodeDto.UserId ?? Constants.Security.UnknownUserId;

            dataType.SetLazyConfiguration(dto.Configuration);

            // reset dirty initial properties (U4-1946)
            dataType.ResetDirtyProperties(false);
            return(dataType);
        }
        finally
        {
            dataType.EnableChangeTracking();
        }
    }
Beispiel #17
0
        public void SetUp()
        {
            var complexEditorConfig = new NestedContentConfiguration
            {
                ContentTypes = new[]
                {
                    new NestedContentConfiguration.ContentType {
                        Alias = "feature"
                    }
                }
            };

            ComplexTestEditor complexTestEditor           = Services.GetRequiredService <ComplexTestEditor>();
            TestEditor        testEditor                  = Services.GetRequiredService <TestEditor>();
            IDataTypeService  dataTypeService             = Services.GetRequiredService <IDataTypeService>();
            IConfigurationEditorJsonSerializer serializer = Services.GetRequiredService <IConfigurationEditorJsonSerializer>();

            var complexDataType = new DataType(complexTestEditor, serializer)
            {
                Name          = "ComplexTest",
                Configuration = complexEditorConfig
            };

            var testDataType = new DataType(testEditor, serializer)
            {
                Name = "Test",
            };

            dataTypeService.Save(complexDataType);
            dataTypeService.Save(testDataType);

            IFileService fileService = Services.GetRequiredService <IFileService>();
            Template     template    = TemplateBuilder.CreateTextPageTemplate();

            fileService.SaveTemplate(template);

            _contentType = ContentTypeBuilder.CreateTextPageContentType(ContentTypeAlias, defaultTemplateId: template.Id);

            // add complex editor
            foreach (IPropertyType pt in _contentType.PropertyTypes)
            {
                pt.DataTypeId = testDataType.Id;
            }

            _contentType.AddPropertyType(
                new PropertyType(_shortStringHelper, "complexTest", ValueStorageType.Ntext)
            {
                Alias = "complex", Name = "Complex", Description = string.Empty, Mandatory = false, SortOrder = 1, DataTypeId = complexDataType.Id
            },
                "content", "Content");

            // make them all validate with a regex rule that will not pass
            foreach (IPropertyType prop in _contentType.PropertyTypes)
            {
                prop.ValidationRegExp        = "^donotmatch$";
                prop.ValidationRegExpMessage = "Does not match!";
            }

            IContentTypeService contentTypeService = Services.GetRequiredService <IContentTypeService>();

            contentTypeService.Save(_contentType);
        }
 public MergeDateAndDateTimePropertyEditor(IMigrationContext context, IIOHelper ioHelper,
                                           IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
     : this(context, ioHelper, configurationEditorJsonSerializer,
            StaticServiceProvider.Instance.GetRequiredService <IEditorConfigurationParser>())
 {
 }