6
6
using Newtonsoft . Json . Linq ;
7
7
8
8
using Umbraco . Courier . Core ;
9
+ using Umbraco . Courier . Core . Logging ;
9
10
using Umbraco . Courier . DataResolvers ;
10
11
using Umbraco . Courier . ItemProviders ;
11
12
@@ -30,9 +31,27 @@ public override void PackagingProperty(Item item, ContentProperty propertyData)
30
31
{
31
32
if ( link . id != null )
32
33
{
33
- link . id = ExecutionContext . DatabasePersistence . GetUniqueId (
34
- ( int ) link . id ,
35
- link . isMedia != null ? NodeObjectTypes . Media : NodeObjectTypes . Document ) ;
34
+ var objectTypeId = link . isMedia != null
35
+ ? UmbracoNodeObjectTypeIds . Media
36
+ : UmbracoNodeObjectTypeIds . Document ;
37
+ var itemProviderId = link . isMedia != null
38
+ ? ItemProviderIds . mediaItemProviderGuid
39
+ : ItemProviderIds . documentItemProviderGuid ;
40
+
41
+ link . id = ExecutionContext . DatabasePersistence . GetUniqueId ( ( int ) link . id , objectTypeId ) ;
42
+ item . Dependencies . Add ( link . id . ToString ( ) , itemProviderId ) ;
43
+ }
44
+ else if ( link . isMedia != null )
45
+ {
46
+ try
47
+ {
48
+ var mediaId = ExecutionContext . DatabasePersistence . GetUniqueIdFromMediaFile ( link . url ) ;
49
+ item . Dependencies . Add ( mediaId . ToString ( ) , ItemProviderIds . mediaItemProviderGuid ) ;
50
+ }
51
+ catch ( Exception e )
52
+ {
53
+ CourierLogHelper . Error < MultiUrlPickerDataResolverProvider > ( string . Format ( "Error setting media-item dependency, name={0}, url={1}" , link . name , link . url ) , e ) ;
54
+ }
36
55
}
37
56
}
38
57
propertyData . Value = links . ToString ( ) ;
@@ -53,10 +72,10 @@ public override void ExtractingProperty(Item item, ContentProperty propertyData)
53
72
{
54
73
link . id = ExecutionContext . DatabasePersistence . GetNodeId (
55
74
( Guid ) link . id ,
56
- link . isMedia != null ? NodeObjectTypes . Media : NodeObjectTypes . Document ) ;
75
+ link . isMedia != null ? UmbracoNodeObjectTypeIds . Media : UmbracoNodeObjectTypeIds . Document ) ;
57
76
}
58
77
}
59
- propertyData . Value = links . ToString ( ) ;
78
+ propertyData . Value = links ;
60
79
}
61
80
}
62
81
}
0 commit comments