You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by bo...@apache.org on 2016/01/31 00:38:35 UTC

svn commit: r1727765 - /tapestry/tapestry-site/trunk/src/main/java/org/apache/cxf/cwiki/SiteExporter.java

Author: bobharner
Date: Sat Jan 30 23:38:35 2016
New Revision: 1727765

URL: http://svn.apache.org/viewvc?rev=1727765&view=rev
Log:
If there is a timeout on a page, continue with the remaining pages (copy of Dan Kulp's rev 1704663 from CXF project's SiteExporter class) 

Modified:
    tapestry/tapestry-site/trunk/src/main/java/org/apache/cxf/cwiki/SiteExporter.java

Modified: tapestry/tapestry-site/trunk/src/main/java/org/apache/cxf/cwiki/SiteExporter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry-site/trunk/src/main/java/org/apache/cxf/cwiki/SiteExporter.java?rev=1727765&r1=1727764&r2=1727765&view=diff
==============================================================================
--- tapestry/tapestry-site/trunk/src/main/java/org/apache/cxf/cwiki/SiteExporter.java (original)
+++ tapestry/tapestry-site/trunk/src/main/java/org/apache/cxf/cwiki/SiteExporter.java Sat Jan 30 23:38:35 2016
@@ -418,33 +418,39 @@ public class SiteExporter implements Run
                                + "    (" + count + "/" + total + ")");
             loadAttachments(p);
             
-            loadPageContent(p, null, null);
-            
-            VelocityContext ctx = new VelocityContext();
-            ctx.put("autoexport", this);
-            ctx.put("page", p);
-            ctx.put("body", p.getContent());
-            ctx.put("confluenceUri", ROOT);
-            ctx.put("pageManager", pageManager);
-            ctx.put("renderer", renderer);
-            ctx.put("exporter", this);
-            
-            File file = new File(outputDir, p.createFileName());
-            boolean isNew = !file.exists();
-            
-            FileWriter writer = new FileWriter(file);
-            ctx.put("out", writer);
-            template.merge(ctx, writer);
-            writer.close();
-            if (isNew) {
-                //call "svn add"
-                callSvn("add", file.getAbsolutePath());
-                svnCommitMessage.append("Adding: " + file.getName() + "\n");
-            } else {
-                svnCommitMessage.append("Modified: " + file.getName() + "\n");                
+            try {
+                loadPageContent(p, null, null);
+                
+                VelocityContext ctx = new VelocityContext();
+                ctx.put("autoexport", this);
+                ctx.put("page", p);
+                ctx.put("body", p.getContent());
+                ctx.put("confluenceUri", ROOT);
+                ctx.put("pageManager", pageManager);
+                ctx.put("renderer", renderer);
+                ctx.put("exporter", this);
+                
+                File file = new File(outputDir, p.createFileName());
+                boolean isNew = !file.exists();
+                
+                FileWriter writer = new FileWriter(file);
+                ctx.put("out", writer);
+                template.merge(ctx, writer);
+                writer.close();
+                if (isNew) {
+                    //call "svn add"
+                    callSvn("add", file.getAbsolutePath());
+                    svnCommitMessage.append("Adding: " + file.getName() + "\n");
+                } else {
+                    svnCommitMessage.append("Modified: " + file.getName() + "\n");                
+                }
+                
+                p.setContent(null);
+            } catch (Exception e) {
+                System.out.println("Could not render page " + p.getTitle() + " due to " + e.getMessage());
+                e.printStackTrace();
             }
-            
-            p.setContent(null);
+
         }
     }
     
@@ -459,36 +465,41 @@ public class SiteExporter implements Run
             System.out.println("(" + spaceKey + ") Rendering Blog Entry " + entry.getTitle() 
                                + "    (" + count + "/" + total + ")");
             
-            loadAttachments(entry);
-            String body = renderPage(entry);
-            body = updateContentLinks(entry, body, null, mainDivClass);
-            
-            pageManager.setDirectory(entry.getDirectory());
-            
-            VelocityContext ctx = new VelocityContext();
-            ctx.put("autoexport", this);
-            ctx.put("page", entry);
-            ctx.put("body", body);
-            ctx.put("confluenceUri", ROOT);
-            ctx.put("pageManager", pageManager);
-            ctx.put("renderer", renderer);
-            ctx.put("exporter", this);
-            ctx.put("isBlogEntry", Boolean.TRUE);
-            
-            File file = new File(outputDir, entry.getPath());
-            file.getParentFile().mkdirs();
-            boolean isNew = !file.exists();
-            
-            FileWriter writer = new FileWriter(file);
-            ctx.put("out", writer);
-            template.merge(ctx, writer);
-            writer.close();
-            if (isNew) {
-                //call "svn add"
-                callSvn("add", file.getAbsolutePath());
-                svnCommitMessage.append("Adding: " + file.getName() + "\n");
-            } else {
-                svnCommitMessage.append("Modified: " + file.getName() + "\n");                
+            try {
+                loadAttachments(entry);
+                String body = renderPage(entry);
+                body = updateContentLinks(entry, body, null, mainDivClass);
+                
+                pageManager.setDirectory(entry.getDirectory());
+                
+                VelocityContext ctx = new VelocityContext();
+                ctx.put("autoexport", this);
+                ctx.put("page", entry);
+                ctx.put("body", body);
+                ctx.put("confluenceUri", ROOT);
+                ctx.put("pageManager", pageManager);
+                ctx.put("renderer", renderer);
+                ctx.put("exporter", this);
+                ctx.put("isBlogEntry", Boolean.TRUE);
+                
+                File file = new File(outputDir, entry.getPath());
+                file.getParentFile().mkdirs();
+                boolean isNew = !file.exists();
+                
+                FileWriter writer = new FileWriter(file);
+                ctx.put("out", writer);
+                template.merge(ctx, writer);
+                writer.close();
+                if (isNew) {
+                    //call "svn add"
+                    callSvn("add", file.getAbsolutePath());
+                    svnCommitMessage.append("Adding: " + file.getName() + "\n");
+                } else {
+                    svnCommitMessage.append("Modified: " + file.getName() + "\n");                
+                }
+            } catch (Exception e) {
+                System.out.println("Could not render blog " + entry.getTitle() + " due to " + e.getMessage());
+                e.printStackTrace();
             }
         }
     }
@@ -1105,6 +1116,7 @@ public class SiteExporter implements Run
         XMLWriter xmlWriter = new ConfluenceCleanupWriter(this, w, page, id, divCls);
         xmlWriter.setOutputProperty(XMLWriter.OMIT_XML_DECLARATION, "yes");
         xmlWriter.setOutputProperty(XMLWriter.METHOD, "html");
+        xmlWriter.setOutputProperty(XMLWriter.INDENT, "yes");
         return xmlWriter;
     }