@@ -61,6 +61,7 @@ public class PublishMappings : TemplateBase
6161
6262 public PublishMappings ( )
6363 {
64+ InternalLogger . Debug ( "PublishMappings TBB constructed" ) ;
6465 foreach ( KeyValuePair < string , string > ns in _namespaces )
6566 {
6667 _namespaceManager . AddNamespace ( ns . Key , ns . Value ) ;
@@ -69,6 +70,7 @@ public PublishMappings()
6970
7071 public override void Transform ( Engine engine , Package package )
7172 {
73+ InternalLogger . Debug ( "Transform called" ) ;
7274 Initialize ( engine , package ) ;
7375
7476 package . TryGetParameter ( "retrofitMode" , out _retrofitMode , Logger ) ;
@@ -88,6 +90,7 @@ public override void Transform(Engine engine, Package package)
8890 AddBootstrapJsonBinary ( binaries , inputComponent , mappingsStructureGroup , "mapping" ) ;
8991
9092 OutputSummary ( "Publish Mappings" , binaries . Select ( b => b ? . Url ) ) ;
93+ InternalLogger . Debug ( "Transform completed" ) ;
9194 }
9295
9396 private Binary PublishSemanticVocabularies ( StructureGroup structureGroup , Component relatedComponent )
@@ -271,18 +274,28 @@ private Binary PublishXpmRegionConfiguration(StructureGroup structureGroup, Comp
271274
272275 private Binary PublishPageIncludes ( StructureGroup structureGroup , Component relatedComponent )
273276 {
277+ InternalLogger . Debug ( $ "PublishPageIncludes(structureGroup='{ structureGroup . Title } , { structureGroup . Id } ', relatedComponent='{ relatedComponent . Title } , { relatedComponent . Id } ')") ;
274278 IDictionary < string , string [ ] > pageIncludes = new Dictionary < string , string [ ] > ( ) ;
275279
276280 RepositoryItemsFilter pageTemplatesFilter = new RepositoryItemsFilter ( Session )
277281 {
278282 ItemTypes = new [ ] { ItemType . PageTemplate } ,
279283 Recursive = true
280284 } ;
281-
285+ InternalLogger . Debug ( "Getting all page templates from publication..." ) ;
282286 IEnumerable < PageTemplate > pageTemplates = Publication . GetItems ( pageTemplatesFilter ) . Cast < PageTemplate > ( ) ;
287+ InternalLogger . Debug ( $ "Found { pageTemplates . Count ( ) } page templates... Checking page template metadata if it exists...") ;
283288 foreach ( PageTemplate pt in pageTemplates . Where ( pt => pt . MetadataSchema != null && pt . Metadata != null ) )
284289 {
290+ InternalLogger . Debug ( $ " page template '{ pt . Title } ' with id '{ pt . Id } ' contains metadata with metadata schema '{ pt . MetadataSchema . Title } ', id = '{ pt . MetadataSchema . Id } '...") ;
285291 ItemFields ptMetadataFields = new ItemFields ( pt . Metadata , pt . MetadataSchema ) ;
292+
293+ InternalLogger . Debug ( $ "Looking for metadata field values with fieldname 'includes'..") ;
294+ var includeFields = ptMetadataFields . GetTextValues ( "includes" ) ;
295+ foreach ( var includeField in includeFields )
296+ {
297+ InternalLogger . Debug ( $ "Found include with value = { includeField } !") ;
298+ }
286299 string [ ] includes = ptMetadataFields . GetTextValues ( "includes" ) . Select ( id => GetPublishPath ( id ) ) . ToArray ( ) ;
287300 pageIncludes . Add ( pt . Id . ItemId . ToString ( ) , includes ) ;
288301 }
@@ -292,17 +305,30 @@ private Binary PublishPageIncludes(StructureGroup structureGroup, Component rela
292305
293306 private string GetPublishPath ( string pageId )
294307 {
295- string result ;
296- if ( TcmUri . IsValid ( pageId ) || pageId . StartsWith ( "/webdav/" ) )
308+ try
297309 {
298- Page page = ( Page ) Session . GetObject ( pageId ) ;
299- result = page . PublishLocationUrl . Substring ( 1 ) ;
310+ InternalLogger . Debug ( $ "GetPublishPath(pageId = { pageId } ) called") ;
311+ string result ;
312+ if ( TcmUri . IsValid ( pageId ) || pageId . StartsWith ( "/webdav/" , StringComparison . InvariantCultureIgnoreCase ) )
313+ {
314+ InternalLogger . Debug ( " PageId is a valid tcm uri or begins with /webdav/ -- attempting to get page object from session" ) ;
315+ Page page = ( Page ) Session . GetObject ( pageId ) ;
316+ result = page . PublishLocationUrl . Substring ( 1 ) ;
317+ InternalLogger . Debug ( $ " Page object from session = { result } ") ;
318+ }
319+ else
320+ {
321+ InternalLogger . Debug ( $ " Using pageId '{ pageId } '") ;
322+ result = pageId ;
323+ }
324+ return result ;
300325 }
301- else
326+ catch
302327 {
303- result = pageId ;
328+ InternalLogger . Debug ( $ " Using pageId ' { pageId } '" ) ;
304329 }
305- return result ;
330+
331+ return pageId ;
306332 }
307333
308334 private SemanticSchemaData GetSemanticSchema ( Schema schema )
0 commit comments