@@ -91,19 +91,25 @@ public InstallationSummary InstallPackageData(CompiledPackage compiledPackage, i
91
91
var installationSummary = new InstallationSummary ( compiledPackage . Name )
92
92
{
93
93
Warnings = compiledPackage . Warnings ,
94
- DataTypesInstalled = ImportDataTypes ( compiledPackage . DataTypes . ToList ( ) , userId ) ,
94
+ DataTypesInstalled = ImportDataTypes ( compiledPackage . DataTypes . ToList ( ) , userId , out IEnumerable < EntityContainer > dataTypeEntityContainersInstalled ) ,
95
95
LanguagesInstalled = ImportLanguages ( compiledPackage . Languages , userId ) ,
96
96
DictionaryItemsInstalled = ImportDictionaryItems ( compiledPackage . DictionaryItems , userId ) ,
97
97
MacrosInstalled = ImportMacros ( compiledPackage . Macros , userId ) ,
98
98
MacroPartialViewsInstalled = ImportMacroPartialViews ( compiledPackage . MacroPartialViews , userId ) ,
99
99
TemplatesInstalled = ImportTemplates ( compiledPackage . Templates . ToList ( ) , userId ) ,
100
- DocumentTypesInstalled = ImportDocumentTypes ( compiledPackage . DocumentTypes , userId ) ,
101
- MediaTypesInstalled = ImportMediaTypes ( compiledPackage . MediaTypes , userId ) ,
100
+ DocumentTypesInstalled = ImportDocumentTypes ( compiledPackage . DocumentTypes , userId , out IEnumerable < EntityContainer > documentTypeEntityContainersInstalled ) ,
101
+ MediaTypesInstalled = ImportMediaTypes ( compiledPackage . MediaTypes , userId , out IEnumerable < EntityContainer > mediaTypeEntityContainersInstalled ) ,
102
102
StylesheetsInstalled = ImportStylesheets ( compiledPackage . Stylesheets , userId ) ,
103
103
ScriptsInstalled = ImportScripts ( compiledPackage . Scripts , userId ) ,
104
104
PartialViewsInstalled = ImportPartialViews ( compiledPackage . PartialViews , userId )
105
105
} ;
106
106
107
+ var entityContainersInstalled = new List < EntityContainer > ( ) ;
108
+ entityContainersInstalled . AddRange ( dataTypeEntityContainersInstalled ) ;
109
+ entityContainersInstalled . AddRange ( documentTypeEntityContainersInstalled ) ;
110
+ entityContainersInstalled . AddRange ( mediaTypeEntityContainersInstalled ) ;
111
+ installationSummary . EntityContainersInstalled = entityContainersInstalled ;
112
+
107
113
// We need a reference to the imported doc types to continue
108
114
var importedDocTypes = installationSummary . DocumentTypesInstalled . ToDictionary ( x => x . Alias , x => x ) ;
109
115
var importedMediaTypes = installationSummary . MediaTypesInstalled . ToDictionary ( x => x . Alias , x => x ) ;
@@ -116,14 +122,25 @@ public InstallationSummary InstallPackageData(CompiledPackage compiledPackage, i
116
122
return installationSummary ;
117
123
}
118
124
}
125
+
119
126
/// <summary>
120
127
/// Imports and saves package xml as <see cref="IContentType"/>
121
128
/// </summary>
122
129
/// <param name="docTypeElements">Xml to import</param>
123
130
/// <param name="userId">Optional id of the User performing the operation. Default is zero (admin).</param>
124
131
/// <returns>An enumerable list of generated ContentTypes</returns>
125
132
public IReadOnlyList < IMediaType > ImportMediaTypes ( IEnumerable < XElement > docTypeElements , int userId )
126
- => ImportDocumentTypes ( docTypeElements . ToList ( ) , true , userId , _mediaTypeService ) ;
133
+ => ImportMediaTypes ( docTypeElements , userId , out _ ) ;
134
+
135
+ /// <summary>
136
+ /// Imports and saves package xml as <see cref="IContentType"/>
137
+ /// </summary>
138
+ /// <param name="docTypeElements">Xml to import</param>
139
+ /// <param name="userId">Optional id of the User performing the operation. Default is zero (admin).</param>
140
+ /// <param name="entityContainersInstalled">Collection of entity containers installed by the package to be populated with those created in installing data types.</param>
141
+ /// <returns>An enumerable list of generated ContentTypes</returns>
142
+ public IReadOnlyList < IMediaType > ImportMediaTypes ( IEnumerable < XElement > docTypeElements , int userId , out IEnumerable < EntityContainer > entityContainersInstalled )
143
+ => ImportDocumentTypes ( docTypeElements . ToList ( ) , true , userId , _mediaTypeService , out entityContainersInstalled ) ;
127
144
128
145
#endregion
129
146
@@ -408,7 +425,7 @@ private TContentBase CreateContent<TContentBase, TContentTypeComposition>(string
408
425
#region DocumentTypes
409
426
410
427
public IReadOnlyList < IContentType > ImportDocumentType ( XElement docTypeElement , int userId )
411
- => ImportDocumentTypes ( new [ ] { docTypeElement } , userId ) ;
428
+ => ImportDocumentTypes ( new [ ] { docTypeElement } , userId , out _ ) ;
412
429
413
430
/// <summary>
414
431
/// Imports and saves package xml as <see cref="IContentType"/>
@@ -417,7 +434,17 @@ public IReadOnlyList<IContentType> ImportDocumentType(XElement docTypeElement, i
417
434
/// <param name="userId">Optional id of the User performing the operation. Default is zero (admin).</param>
418
435
/// <returns>An enumerable list of generated ContentTypes</returns>
419
436
public IReadOnlyList < IContentType > ImportDocumentTypes ( IEnumerable < XElement > docTypeElements , int userId )
420
- => ImportDocumentTypes ( docTypeElements . ToList ( ) , true , userId , _contentTypeService ) ;
437
+ => ImportDocumentTypes ( docTypeElements . ToList ( ) , true , userId , _contentTypeService , out _ ) ;
438
+
439
+ /// <summary>
440
+ /// Imports and saves package xml as <see cref="IContentType"/>
441
+ /// </summary>
442
+ /// <param name="docTypeElements">Xml to import</param>
443
+ /// <param name="userId">Optional id of the User performing the operation. Default is zero (admin).</param>
444
+ /// <param name="entityContainersInstalled">Collection of entity containers installed by the package to be populated with those created in installing data types.</param>
445
+ /// <returns>An enumerable list of generated ContentTypes</returns>
446
+ public IReadOnlyList < IContentType > ImportDocumentTypes ( IEnumerable < XElement > docTypeElements , int userId , out IEnumerable < EntityContainer > entityContainersInstalled )
447
+ => ImportDocumentTypes ( docTypeElements . ToList ( ) , true , userId , _contentTypeService , out entityContainersInstalled ) ;
421
448
422
449
/// <summary>
423
450
/// Imports and saves package xml as <see cref="IContentType"/>
@@ -428,6 +455,18 @@ public IReadOnlyList<IContentType> ImportDocumentTypes(IEnumerable<XElement> doc
428
455
/// <returns>An enumerable list of generated ContentTypes</returns>
429
456
public IReadOnlyList < T > ImportDocumentTypes < T > ( IReadOnlyCollection < XElement > unsortedDocumentTypes , bool importStructure , int userId , IContentTypeBaseService < T > service )
430
457
where T : class , IContentTypeComposition
458
+ => ImportDocumentTypes ( unsortedDocumentTypes , importStructure , userId , service ) ;
459
+
460
+ /// <summary>
461
+ /// Imports and saves package xml as <see cref="IContentType"/>
462
+ /// </summary>
463
+ /// <param name="unsortedDocumentTypes">Xml to import</param>
464
+ /// <param name="importStructure">Boolean indicating whether or not to import the </param>
465
+ /// <param name="userId">Optional id of the User performing the operation. Default is zero (admin).</param>
466
+ /// <param name="entityContainersInstalled">Collection of entity containers installed by the package to be populated with those created in installing data types.</param>
467
+ /// <returns>An enumerable list of generated ContentTypes</returns>
468
+ public IReadOnlyList < T > ImportDocumentTypes < T > ( IReadOnlyCollection < XElement > unsortedDocumentTypes , bool importStructure , int userId , IContentTypeBaseService < T > service , out IEnumerable < EntityContainer > entityContainersInstalled )
469
+ where T : class , IContentTypeComposition
431
470
{
432
471
var importedContentTypes = new Dictionary < string , T > ( ) ;
433
472
@@ -436,7 +475,7 @@ public IReadOnlyList<T> ImportDocumentTypes<T>(IReadOnlyCollection<XElement> uns
436
475
var graph = new TopoGraph < string , TopoGraph . Node < string , XElement > > ( x => x . Key , x => x . Dependencies ) ;
437
476
var isSingleDocTypeImport = unsortedDocumentTypes . Count == 1 ;
438
477
439
- var importedFolders = CreateContentTypeFolderStructure ( unsortedDocumentTypes ) ;
478
+ var importedFolders = CreateContentTypeFolderStructure ( unsortedDocumentTypes , out entityContainersInstalled ) ;
440
479
441
480
if ( isSingleDocTypeImport == false )
442
481
{
@@ -532,9 +571,10 @@ public IReadOnlyList<T> ImportDocumentTypes<T>(IReadOnlyCollection<XElement> uns
532
571
return list ;
533
572
}
534
573
535
- private Dictionary < string , int > CreateContentTypeFolderStructure ( IEnumerable < XElement > unsortedDocumentTypes )
574
+ private Dictionary < string , int > CreateContentTypeFolderStructure ( IEnumerable < XElement > unsortedDocumentTypes , out IEnumerable < EntityContainer > entityContainersInstalled )
536
575
{
537
576
var importedFolders = new Dictionary < string , int > ( ) ;
577
+ var trackEntityContainersInstalled = new List < EntityContainer > ( ) ;
538
578
foreach ( var documentType in unsortedDocumentTypes )
539
579
{
540
580
var foldersAttribute = documentType . Attribute ( "Folders" ) ;
@@ -578,8 +618,10 @@ private Dictionary<string, int> CreateContentTypeFolderStructure(IEnumerable<XEl
578
618
_logger . LogError ( tryCreateFolder . Exception , "Could not create folder: {FolderName}" , rootFolder ) ;
579
619
throw tryCreateFolder . Exception ;
580
620
}
621
+
581
622
var rootFolderId = tryCreateFolder . Result . Entity . Id ;
582
623
current = _contentTypeService . GetContainer ( rootFolderId ) ;
624
+ trackEntityContainersInstalled . Add ( current ) ;
583
625
}
584
626
585
627
importedFolders . Add ( alias , current . Id ) ;
@@ -589,11 +631,13 @@ private Dictionary<string, int> CreateContentTypeFolderStructure(IEnumerable<XEl
589
631
var folderName = WebUtility . UrlDecode ( folders [ i ] ) ;
590
632
Guid ? folderKey = ( folderKeys . Length == folders . Length ) ? folderKeys [ i ] : null ;
591
633
current = CreateContentTypeChildFolder ( folderName , folderKey ?? Guid . NewGuid ( ) , current ) ;
634
+ trackEntityContainersInstalled . Add ( current ) ;
592
635
importedFolders [ alias ] = current . Id ;
593
636
}
594
637
}
595
638
}
596
639
640
+ entityContainersInstalled = trackEntityContainersInstalled ;
597
641
return importedFolders ;
598
642
}
599
643
@@ -1012,10 +1056,20 @@ private T FindContentTypeByAlias<T>(string contentTypeAlias, IContentTypeBaseSer
1012
1056
/// <param name="userId">Optional id of the user</param>
1013
1057
/// <returns>An enumerable list of generated DataTypeDefinitions</returns>
1014
1058
public IReadOnlyList < IDataType > ImportDataTypes ( IReadOnlyCollection < XElement > dataTypeElements , int userId )
1059
+ => ImportDataTypes ( dataTypeElements , userId , out _ ) ;
1060
+
1061
+ /// <summary>
1062
+ /// Imports and saves package xml as <see cref="IDataType"/>
1063
+ /// </summary>
1064
+ /// <param name="dataTypeElements">Xml to import</param>
1065
+ /// <param name="userId">Optional id of the user</param>
1066
+ /// <param name="entityContainersInstalled">Collection of entity containers installed by the package to be populated with those created in installing data types.</param>
1067
+ /// <returns>An enumerable list of generated DataTypeDefinitions</returns>
1068
+ public IReadOnlyList < IDataType > ImportDataTypes ( IReadOnlyCollection < XElement > dataTypeElements , int userId , out IEnumerable < EntityContainer > entityContainersInstalled )
1015
1069
{
1016
1070
var dataTypes = new List < IDataType > ( ) ;
1017
1071
1018
- var importedFolders = CreateDataTypeFolderStructure ( dataTypeElements ) ;
1072
+ var importedFolders = CreateDataTypeFolderStructure ( dataTypeElements , out entityContainersInstalled ) ;
1019
1073
1020
1074
foreach ( var dataTypeElement in dataTypeElements )
1021
1075
{
@@ -1072,9 +1126,10 @@ public IReadOnlyList<IDataType> ImportDataTypes(IReadOnlyCollection<XElement> da
1072
1126
return dataTypes ;
1073
1127
}
1074
1128
1075
- private Dictionary < string , int > CreateDataTypeFolderStructure ( IEnumerable < XElement > datatypeElements )
1129
+ private Dictionary < string , int > CreateDataTypeFolderStructure ( IEnumerable < XElement > datatypeElements , out IEnumerable < EntityContainer > entityContainersInstalled )
1076
1130
{
1077
1131
var importedFolders = new Dictionary < string , int > ( ) ;
1132
+ var trackEntityContainersInstalled = new List < EntityContainer > ( ) ;
1078
1133
foreach ( var datatypeElement in datatypeElements )
1079
1134
{
1080
1135
var foldersAttribute = datatypeElement . Attribute ( "Folders" ) ;
@@ -1103,7 +1158,9 @@ private Dictionary<string, int> CreateDataTypeFolderStructure(IEnumerable<XEleme
1103
1158
_logger . LogError ( tryCreateFolder . Exception , "Could not create folder: {FolderName}" , rootFolder ) ;
1104
1159
throw tryCreateFolder . Exception ;
1105
1160
}
1161
+
1106
1162
current = _dataTypeService . GetContainer ( tryCreateFolder . Result . Entity . Id ) ;
1163
+ trackEntityContainersInstalled . Add ( current ) ;
1107
1164
}
1108
1165
1109
1166
importedFolders . Add ( name , current . Id ) ;
@@ -1113,11 +1170,12 @@ private Dictionary<string, int> CreateDataTypeFolderStructure(IEnumerable<XEleme
1113
1170
var folderName = WebUtility . UrlDecode ( folders [ i ] ) ;
1114
1171
Guid ? folderKey = ( folderKeys . Length == folders . Length ) ? folderKeys [ i ] : null ;
1115
1172
current = CreateDataTypeChildFolder ( folderName , folderKey ?? Guid . NewGuid ( ) , current ) ;
1173
+ trackEntityContainersInstalled . Add ( current ) ;
1116
1174
importedFolders [ name ] = current . Id ;
1117
1175
}
1118
1176
}
1119
1177
}
1120
-
1178
+ entityContainersInstalled = trackEntityContainersInstalled ;
1121
1179
return importedFolders ;
1122
1180
}
1123
1181
0 commit comments