UpdatePageDivs() public method

public UpdatePageDivs ( ) : void
return void
        /// <summary>
        /// Do whatever is needed to do more than just show a title and thumbnail
        /// </summary>
        private void ExpensiveInitialization()
        {
            Debug.WriteLine(string.Format("ExpensiveInitialization({0})", _folderPath));
            _dom = new HtmlDom();
            //the fileLocator we get doesn't know anything about this particular book.
            _fileLocator.AddPath(_folderPath);
            RequireThat.Directory(_folderPath).Exists();
            if (!File.Exists(PathToExistingHtml))
            {
                var files = new List <string>(Directory.GetFiles(_folderPath));
                var b     = new StringBuilder();
                b.AppendLine("Could not determine which html file in the folder to use.");
                if (files.Count == 0)
                {
                    b.AppendLine("***There are no files.");
                }
                else
                {
                    b.AppendLine("Files in this book are:");
                    foreach (var f in files)
                    {
                        b.AppendLine("  " + f);
                    }
                }
                throw new ApplicationException(b.ToString());
            }
            else
            {
                var xmlDomFromHtmlFile = XmlHtmlConverter.GetXmlDomFromHtmlFile(PathToExistingHtml, false);
                _dom = new HtmlDom(xmlDomFromHtmlFile);                 //with throw if there are errors

                //Validating here was taking a 1/3 of the startup time
                // eventually, we need to restructure so that this whole Storage isn't created until actually needed, then maybe this can come back
                //ErrorMessages = ValidateBook(PathToExistingHtml);
                // REVIEW: we did in fact change things so that storage isn't used until we've shown all the thumbnails we can (then we go back and update in background)...
                // so maybe it would be ok to reinstate the above?

                //For now, we really need to do this check, at least. This will get picked up by the Book later (feeling kludgy!)
                //I assume the following will never trigger (I also note that the dom isn't even loaded):


                if (!string.IsNullOrEmpty(ErrorMessages))
                {
                    //hack so we can package this for palaso reporting
//                    var ex = new XmlSyntaxException(ErrorMessages);
//                    Palaso.Reporting.ErrorReport.NotifyUserOfProblem(ex, "Bloom did an integrity check of the book named '{0}', and found something wrong. This doesn't mean your work is lost, but it does mean that there is a bug in the system or templates somewhere, and the developers need to find and fix the problem (and your book).  Please click the 'Details' button and send this report to the developers.", Path.GetFileName(PathToExistingHtml));
                    _dom.RawDom.LoadXml(
                        "<html><body>There is a problem with the html structure of this book which will require expert help.</body></html>");
                    Logger.WriteEvent(
                        "{0}: There is a problem with the html structure of this book which will require expert help: {1}",
                        PathToExistingHtml, ErrorMessages);
                }
                //The following is a patch pushed out on the 25th build after 1.0 was released in order to give us a bit of backwards version protection (I should have done this originally and in a less kludgy fashion than I'm forced to do now)
                else
                {
                    var incompatibleVersionMessage = GetMessageIfVersionIsIncompatibleWithThisBloom(Dom);
                    if (!string.IsNullOrWhiteSpace(incompatibleVersionMessage))
                    {
                        _dom.RawDom.LoadXml(
                            "<html><body style='background-color: white'><p/><p/><p/>" + WebUtility.HtmlEncode(incompatibleVersionMessage) + "</body></html>");
                        Logger.WriteEvent(PathToExistingHtml + " " + incompatibleVersionMessage);
                    }
                    else
                    {
                        Logger.WriteEvent("BookStorage Loading Dom from {0}", PathToExistingHtml);
                    }
                }

                //TODO: this would be better just to add to those temporary copies of it. As it is, we have to remove it for the webkit printing
                //SetBaseForRelativePaths(Dom, folderPath); //needed because the file itself may be off in the temp directory

                //UpdateStyleSheetLinkPaths(fileLocator);

                Dom.UpdatePageDivs();

                UpdateSupportFiles();
            }
        }