@@ -39,21 +39,36 @@ public BlockEditorValueConnector(IContentTypeService contentTypeService, Lazy<Va
39
39
40
40
public string ToArtifact ( object value , PropertyType propertyType , ICollection < ArtifactDependency > dependencies )
41
41
{
42
+ _logger . Info < BlockEditorValueConnector > ( "Converting {PropertyType} to artifact." , propertyType . Alias ) ;
42
43
var svalue = value as string ;
43
44
44
45
// nested values will arrive here as JObject - convert to string to enable reuse of same code as when non-nested.
45
46
if ( value is JObject )
47
+ {
48
+ _logger . Debug < BlockListValueConnector > ( "Value is a JObject - converting to string." ) ;
46
49
svalue = value . ToString ( ) ;
50
+ }
47
51
48
52
if ( string . IsNullOrWhiteSpace ( svalue ) )
53
+ {
54
+ _logger . Warn < BlockEditorValueConnector > ( $ "Value is null or whitespace. Skipping creating artifact.") ;
49
55
return null ;
56
+ }
50
57
51
58
if ( svalue . DetectIsJson ( ) == false )
59
+ {
60
+ _logger . Warn < BlockListValueConnector > ( "Value {Value} is not a json string. Skipping creating artifact." ,
61
+ svalue ) ;
52
62
return null ;
63
+ }
64
+
53
65
var blockEditorValue = JsonConvert . DeserializeObject < BlockEditorValue > ( svalue ) ;
54
66
55
67
if ( blockEditorValue == null )
68
+ {
69
+ _logger . Warn < BlockEditorValueConnector > ( "Deserialized value is null. Skipping creating artifact." ) ;
56
70
return null ;
71
+ }
57
72
58
73
var allBlocks = blockEditorValue . Content . Concat ( blockEditorValue . Settings ) ;
59
74
@@ -76,6 +91,7 @@ public string ToArtifact(object value, PropertyType propertyType, ICollection<Ar
76
91
//Ensure that these content types have dependencies added
77
92
foreach ( var contentType in allContentTypes . Values )
78
93
{
94
+ _logger . Debug < BlockEditorValueConnector > ( "Adding dependency for content type {ContentType}." , contentType . Alias ) ;
79
95
dependencies . Add ( new ArtifactDependency ( contentType . GetUdi ( ) , false , ArtifactDependencyMode . Match ) ) ;
80
96
}
81
97
@@ -89,7 +105,7 @@ public string ToArtifact(object value, PropertyType propertyType, ICollection<Ar
89
105
90
106
if ( propType == null )
91
107
{
92
- _logger . Debug < BlockEditorValueConnector > ( "No property type found with alias {Key} on content type {ContentTypeAlias}." , key , contentType . Alias ) ;
108
+ _logger . Warn < BlockEditorValueConnector > ( "No property type found with alias {Key} on content type {ContentTypeAlias}." , key , contentType . Alias ) ;
93
109
continue ;
94
110
}
95
111
@@ -101,7 +117,7 @@ public string ToArtifact(object value, PropertyType propertyType, ICollection<Ar
101
117
var val = block . PropertyValues [ key ] ;
102
118
object parsedValue = propValueConnector . ToArtifact ( val , propType , dependencies ) ;
103
119
104
- _logger . Debug < BlockEditorValueConnector > ( "Map {Key} value '{PropertyValue}' to '{ParsedValue}' using {PropValueConnectorType} for {PropTypeAlias}." , key , block . PropertyValues [ key ] , parsedValue , propValueConnector . GetType ( ) , propType . Alias ) ;
120
+ _logger . Debug < BlockEditorValueConnector > ( "Mapped {Key} value '{PropertyValue}' to '{ParsedValue}' using {PropValueConnectorType} for {PropTypeAlias}." , key , block . PropertyValues [ key ] , parsedValue , propValueConnector . GetType ( ) , propType . Alias ) ;
105
121
106
122
parsedValue = parsedValue ? . ToString ( ) ;
107
123
@@ -110,7 +126,8 @@ public string ToArtifact(object value, PropertyType propertyType, ICollection<Ar
110
126
}
111
127
112
128
value = JsonConvert . SerializeObject ( blockEditorValue ) ;
113
- return ( string ) value ;
129
+ _logger . Info < BlockEditorValueConnector > ( "Finished converting {PropertyType} to artifact." , propertyType . Alias ) ;
130
+ return ( string ) value ;
114
131
}
115
132
116
133
public object FromArtifact ( string value , PropertyType propertyType , object currentValue )
@@ -155,7 +172,7 @@ public object FromArtifact(string value, PropertyType propertyType, object curre
155
172
156
173
if ( innerPropertyType == null )
157
174
{
158
- _logger . Debug < BlockEditorValueConnector > ( "No property type found with alias {Key} on content type {ContentTypeAlias}." , key , contentType . Alias ) ;
175
+ _logger . Warn < BlockEditorValueConnector > ( "No property type found with alias {Key} on content type {ContentTypeAlias}." , key , contentType . Alias ) ;
159
176
continue ;
160
177
}
161
178
0 commit comments