@ SuppressWarnings ( "unchecked" ) private void processImageLocations ( final BuildData buildData ) { final List < Integer > topicIds = buildData . getBuildDatabase ( ) . getTopicIds ( ) ; for ( final Integer topicId : topicIds ) { final ITopicNode topicNode = buildData . getBuildDatabase ( ) . getTopicNodesForTopicID ( topicId ) . get ( 0 ) ; final BaseTopicWrapper < ? > topic = topicNode . getTopic ( ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "\tProcessing SpecTopic " + topicNode . getId ( ) + ( topicNode . getRevision ( ) != null ? ( ", " + "Revision " + topicNode . getRevision ( ) ) : "" ) ) ; /* * Images have to be in the image folder in Publican. Here we loop through all the imagedata elements and fix up any * reference to an image that is not in the images folder. */ final List < Node > images = XMLUtilities . getChildNodes ( topicNode . getXMLDocument ( ) , "imagedata" , "inlinegraphic" ) ; for ( final Node imageNode : images ) { final NamedNodeMap attributes = imageNode . getAttributes ( ) ; if ( attributes != null ) { final Node fileRefAttribute = attributes . getNamedItem ( "fileref" ) ; if ( fileRefAttribute != null && ( fileRefAttribute . getNodeValue ( ) == null || fileRefAttribute . getNodeValue ( ) . isEmpty ( ) ) ) { fileRefAttribute . setNodeValue ( "images/" + BuilderConstants . FAILPENGUIN_PNG_NAME + ".jpg" ) ; buildData . getImageLocations ( ) . add ( new TopicImageData ( topic , fileRefAttribute . getNodeValue ( ) ) ) ; } else if ( fileRefAttribute != null && fileRefAttribute . getNodeValue ( ) != null ) { final String fileRefValue = fileRefAttribute . getNodeValue ( ) ; if ( BuilderConstants . IMAGE_FILE_REF_PATTERN . matcher ( fileRefValue ) . matches ( ) ) { if ( fileRefValue . startsWith ( "./images/" ) ) { fileRefAttribute . setNodeValue ( fileRefValue . substring ( 2 ) ) ; } else if ( ! fileRefValue . startsWith ( "images/" ) ) { fileRefAttribute . setNodeValue ( "images/" + fileRefValue ) ; } buildData . getImageLocations ( ) . add ( new TopicImageData ( topic , fileRefAttribute . getNodeValue ( ) ) ) ; } else if ( ! BuilderConstants . COMMON_CONTENT_FILE_REF_PATTERN . matcher ( fileRefValue ) . matches ( ) ) { // The file isn't common content or a pressgang image so mark it as a missing image. fileRefAttribute . setNodeValue ( "images/" + BuilderConstants . FAILPENGUIN_PNG_NAME + ".jpg" ) ; buildData . getImageLocations ( ) . add ( new TopicImageData ( topic , fileRefAttribute . getNodeValue ( ) ) ) ; } } } } } }
Processes the Topics in the BuildDatabase and builds up the images found within the topics XML . If the image reference is blank or invalid it is replaced by the fail penguin image .