cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1297831 - in /cxf/web/src/main/java/org/apache/cxf/cwiki: ConfluenceCleanupWriter.java SiteExporter.java
Date Wed, 07 Mar 2012 01:54:07 GMT
Author: dkulp
Date: Wed Mar  7 01:54:07 2012
New Revision: 1297831

URL: http://svn.apache.org/viewvc?rev=1297831&view=rev
Log:
Updates to provide some more options to help get Camel working
Remove nowrap from <td> which is causing some flow issues

Modified:
    cxf/web/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java
    cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java

Modified: cxf/web/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java
URL: http://svn.apache.org/viewvc/cxf/web/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java?rev=1297831&r1=1297830&r2=1297831&view=diff
==============================================================================
--- cxf/web/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java (original)
+++ cxf/web/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java Wed Mar  7 01:54:07
2012
@@ -39,14 +39,17 @@ public class ConfluenceCleanupWriter ext
     private final Page page;
     private final SiteExporter exporter;
     private final String divId;
+    private final String divCls;
     private final Stack<Integer> trStack = new Stack<Integer>(); 
     private int curTrCount;
 
-    public ConfluenceCleanupWriter(SiteExporter exp, Writer writer, Page page, String id)
{
+    public ConfluenceCleanupWriter(SiteExporter exp, Writer writer, Page page, 
+                                   String id, String divCls) {
         super(writer);
         this.page = page;
         this.exporter = exp;
         this.divId = id;
+        this.divCls = divCls;
     }
 
     public void startElement(String uri, String localName, String qName, final Attributes
atts)
@@ -61,6 +64,14 @@ public class ConfluenceCleanupWriter ext
                     params = href.substring(href.indexOf('#'));
                     href = href.substring(0, href.indexOf('#'));
                 }
+                if (href.indexOf('?') != -1) {
+                    if (params.length() > 0) {
+                        params = href.substring(href.indexOf('?')) + "#" + params;
+                    } else {
+                        params = href.substring(href.indexOf('?'));
+                    }
+                    href = href.substring(0, href.indexOf('?'));
+                }
                 try {
                     final Page p = exporter.findPageByURL(href);
                     if (p != null) {
@@ -142,7 +153,7 @@ public class ConfluenceCleanupWriter ext
         } else if ("td".equals(localName.toLowerCase())
             || "td".equals(qName.toLowerCase())) {
             curTrCount++;
-            newAtts.addMapping("nowrap", "nowrap");            
+            //newAtts.addMapping("nowrap", "nowrap");            
         } else if ("tr".equals(localName.toLowerCase())
             || "tr".equals(qName.toLowerCase())) {
             trStack.push(curTrCount);
@@ -150,8 +161,14 @@ public class ConfluenceCleanupWriter ext
         } else if ("div".equals(localName.toLowerCase())
             || "div".equals(qName.toLowerCase())) {
             String id = atts.getValue("id");
-            if ("ConfluenceContent".equals(id) && divId != null) {
-                newAtts.addMapping("id", divId);
+            if ("ConfluenceContent".equals(id)) {
+                if (divCls != null) {
+                    newAtts.addMapping("class", divCls);
+                    newAtts.remove("id");
+                }
+                if (divId != null) {
+                    newAtts.addMapping("id", divId);
+                } 
             }
         }
         super.startElement(uri, localName, qName, newAtts);

Modified: cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java
URL: http://svn.apache.org/viewvc/cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java?rev=1297831&r1=1297830&r2=1297831&view=diff
==============================================================================
--- cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java (original)
+++ cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java Wed Mar  7 01:54:07 2012
@@ -66,6 +66,8 @@ import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.interceptor.LoggingInInterceptor;
 import org.apache.cxf.interceptor.LoggingOutInterceptor;
 import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.transport.http.HTTPConduit;
+import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.Velocity;
@@ -104,7 +106,9 @@ public class SiteExporter implements Run
     String spaceKey = "CXF";
     String pageCacheFile = "pagesConfig.obj";
     String templateName = "template/template.vm";
+    String mainDivClass;
     boolean forceAll;
+    String breadCrumbRoot;
     
     File outputDir = rootOutputDir;
 
@@ -128,6 +132,12 @@ public class SiteExporter implements Run
         if (props.containsKey("outputDir")) {
             outputDir = new File(rootOutputDir, props.getProperty("outputDir"));
         }
+        if (props.containsKey("mainDivClass")) {
+            mainDivClass = props.getProperty("mainDivClass");
+        }
+        if (props.containsKey("breadCrumbRoot")) {
+            breadCrumbRoot = props.getProperty("breadCrumbRoot");
+        }
         if (props.containsKey("globalPages")) {
             String globals = props.getProperty("globalPages");
             String[] pgs = globals.split(",");
@@ -167,6 +177,16 @@ public class SiteExporter implements Run
                 ((org.apache.cxf.jaxws.DispatchImpl<?>)dispatch).getClient()
                     .getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
             }
+            HTTPConduit c = (HTTPConduit)((org.apache.cxf.jaxws.DispatchImpl<?>)dispatch)
+                .getClient().getConduit();
+            HTTPClientPolicy clientPol = c.getClient();
+            if (clientPol == null) {
+                clientPol = new HTTPClientPolicy();
+            }
+            //CAMEL has a couple of HUGE HUGE pages that take a long time to render
+            clientPol.setReceiveTimeout(5 * 60 * 1000);
+            c.setClient(clientPol);
+            
         }
         return dispatch;
     }
@@ -195,7 +215,7 @@ public class SiteExporter implements Run
         // debug stuff, force regen of a page
         //forcePage("Navigation");
         //forcePage("Index");
-        //forcePage("Custom Transport");
+        //forcePage("JavaDoc");
         
         if (modifiedPages.isEmpty() && checkRSS()) {
             System.out.println("(" + spaceKey + ") No changes detected from RSS");
@@ -282,7 +302,7 @@ public class SiteExporter implements Run
                                + "    (" + count + "/" + total + ")");
             loadAttachments(p);
             
-            loadPageContent(p, null);
+            loadPageContent(p, null, null);
             VelocityContext ctx = new VelocityContext();
             ctx.put("exporter", this);
             ctx.put("page", p);
@@ -428,6 +448,14 @@ public class SiteExporter implements Run
             parentId = parent.getParentId();
             parent = pages.get(parentId);
         }
+        if (breadCrumbRoot != null) {
+            buffer.append("<a href=\"");
+            buffer.append("index.html");
+            buffer.append("\">");
+            buffer.append(breadCrumbRoot);
+            buffer.append("</a>");
+            buffer.append(s);
+        }
         for (Page p2 : p) {
             buffer.append("<a href=\"");
             buffer.append(p2.createFileName());
@@ -449,7 +477,15 @@ public class SiteExporter implements Run
         Page p = findPage(title);
         String s = p.getContentForDivId(divId);
         if (s == null) {
-            s = loadPageContent(p, divId);
+            s = loadPageContent(p, divId, null);
+        }
+        return s;
+    }
+    public String getPageContent(String title, String divId, String cls) throws Exception
{
+        Page p = findPage(title);
+        String s = p.getContentForDivId(divId);
+        if (s == null) {
+            s = loadPageContent(p, divId, cls);
         }
         return s;
     }
@@ -457,11 +493,11 @@ public class SiteExporter implements Run
         Page p = findPage(title);
         String s = p.getContent();
         if (s == null) {
-            loadPageContent(p, null);
+            loadPageContent(p, null, null);
         }
         return p.getContent();
     }
-    private String loadPageContent(Page p, String divId) throws Exception {
+    private String loadPageContent(Page p, String divId, String divCls) throws Exception
{
         Document doc = XMLUtils.newDocument();
         Element el = doc.createElementNS(SOAPNS, "ns1:renderContent");
         Element el2 = doc.createElement("in0");
@@ -496,7 +532,8 @@ public class SiteExporter implements Run
         doc = getDispatch().invoke(doc);
         
         String content = doc.getDocumentElement().getFirstChild().getTextContent().trim();
-        content = updateContentLinks(p, content, divId);
+        content = updateContentLinks(p, content, divId, 
+                                     divCls == null && divId == null ? mainDivClass
: divCls);
         if (divId == null) {
             p.setContent(content);
         } else {
@@ -651,10 +688,11 @@ public class SiteExporter implements Run
         }
     }    
     
-    private String updateContentLinks(Page page, String content, String id) throws Exception
{
+    private String updateContentLinks(Page page, String content,
+                                      String id, String divCls) throws Exception {
         XMLReader parser = createTagSoupParser();
         StringWriter w = new StringWriter();
-        parser.setContentHandler(createContentHandler(page, w, id));
+        parser.setContentHandler(createContentHandler(page, w, id, divCls));
         parser.parse(new InputSource(new StringReader(content)));
         content = w.toString();
         content = content.substring("<html><body>".length());
@@ -674,8 +712,9 @@ public class SiteExporter implements Run
 
         return reader;
     }
-    protected ContentHandler createContentHandler(final Page page, Writer w, String id) {
-        XMLWriter xmlWriter = new ConfluenceCleanupWriter(this, w, page, id);
+    protected ContentHandler createContentHandler(final Page page, Writer w, 
+                                                  String id, String divCls) {
+        XMLWriter xmlWriter = new ConfluenceCleanupWriter(this, w, page, id, divCls);
         xmlWriter.setOutputProperty(XMLWriter.OMIT_XML_DECLARATION, "yes");
         xmlWriter.setOutputProperty(XMLWriter.METHOD, "html");
         return xmlWriter;



Mime
View raw message