You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2011/01/31 23:17:47 UTC

svn commit: r1065833 - in /cxf/web: ./ demos/ docs/ images/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/cxf/ src/main/java/org/apache/cxf/cwiki/ src/main/resources/

Author: dkulp
Date: Mon Jan 31 22:17:46 2011
New Revision: 1065833

URL: http://svn.apache.org/viewvc?rev=1065833&view=rev
Log:
Add some stuff I'm playing with to use an external program to export the CXF spaces from confluence instead of the auto-export plugin

Added:
    cxf/web/README   (with props)
    cxf/web/pom.xml   (with props)
    cxf/web/src/
    cxf/web/src/main/
    cxf/web/src/main/java/
    cxf/web/src/main/java/org/
    cxf/web/src/main/java/org/apache/
    cxf/web/src/main/java/org/apache/cxf/
    cxf/web/src/main/java/org/apache/cxf/cwiki/
    cxf/web/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java   (with props)
    cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java   (with props)
    cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java   (with props)
    cxf/web/src/main/resources/
    cxf/web/src/main/resources/template.vm
Removed:
    cxf/web/demos/
    cxf/web/designs.html
    cxf/web/docs/
    cxf/web/get_involved.html
    cxf/web/images/
    cxf/web/index.html
    cxf/web/license.txt
    cxf/web/mail_list.html
    cxf/web/news.html
    cxf/web/roadmap.html
    cxf/web/site.css
    cxf/web/source.html
Modified:
    cxf/web/   (props changed)

Propchange: cxf/web/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jan 31 22:17:46 2011
@@ -0,0 +1,10 @@
+.pmd
+.checkstyle
+.ruleset
+target
+eclipse-classes
+.settings
+.classpath
+.project
+.wtpmodules
+velocity.log

Added: cxf/web/README
URL: http://svn.apache.org/viewvc/cxf/web/README?rev=1065833&view=auto
==============================================================================
--- cxf/web/README (added)
+++ cxf/web/README Mon Jan 31 22:17:46 2011
@@ -0,0 +1,19 @@
+
+This is the start of an export utility to export the CXF
+confluence spaces to the sites.
+
+Build:
+mvn install
+
+To export the docs space:
+mvn -Pdocs exec:java
+should appear in target/docs
+
+
+To export the main space:
+mvn -Pmain exec:java
+should appear in target/main
+
+
+
+

Propchange: cxf/web/README
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/web/README
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cxf/web/pom.xml
URL: http://svn.apache.org/viewvc/cxf/web/pom.xml?rev=1065833&view=auto
==============================================================================
--- cxf/web/pom.xml (added)
+++ cxf/web/pom.xml Mon Jan 31 22:17:46 2011
@@ -0,0 +1,110 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements. See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership. The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License. You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied. See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.cxf</groupId>
+    <artifactId>cxf-site-export</artifactId>
+    <packaging>jar</packaging>
+    <version>1.0-SNAPSHOT</version>
+    <name>Apache CXF Condfluence Site Exporter</name>
+    <url>http://cxf.apache.org</url>
+
+    <parent>
+        <groupId>org.apache.cxf</groupId>
+        <artifactId>cxf-parent</artifactId>
+        <version>2.3.2</version>
+    </parent>
+
+    <properties>
+        <cxf.version>2.4.0-SNAPSHOT</cxf.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxws</artifactId>
+            <version>${cxf.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http</artifactId>
+            <version>${cxf.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.velocity</groupId>
+            <artifactId>velocity</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.ccil.cowan.tagsoup</groupId>
+            <artifactId>tagsoup</artifactId>
+            <version>1.2</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <configuration>
+                        <source>1.6</source>
+                        <target>1.6</target>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <groupId>org.codehaus.mojo</groupId>
+                    <artifactId>exec-maven-plugin</artifactId>
+                    <version>1.2</version>
+                    <configuration>
+                        <mainClass>org.apache.cxf.cwiki.SiteExporter</mainClass>
+                        <arguments>
+                            <argument>-cache</argument>
+                            <argument>${cache.file}</argument>
+                            <argument>-d</argument>
+                            <argument>${output.dir}</argument>
+                            <argument>-space</argument>
+                            <argument>${space.key}</argument>
+                        </arguments>
+                    </configuration>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
+
+
+    <profiles>
+        <profile>
+            <id>docs</id>
+            <properties>
+                <cache.file>${basedir}/cache/docs.pageCache</cache.file>
+                <output.dir>${basedir}/target/docs</output.dir>
+                <space.key>CXF20DOC</space.key>
+            </properties>
+        </profile>
+        <profile>
+            <id>main</id>
+            <properties>
+                <cache.file>${basedir}/cache/main.pageCache</cache.file>
+                <output.dir>${basedir}/target/main</output.dir>
+                <space.key>CXF</space.key>
+            </properties>
+        </profile>
+    </profiles>
+</project>

Propchange: cxf/web/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/web/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/web/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: 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=1065833&view=auto
==============================================================================
--- cxf/web/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java (added)
+++ cxf/web/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java Mon Jan 31 22:17:46 2011
@@ -0,0 +1,177 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.cwiki;
+
+import java.io.Writer;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import org.ccil.cowan.tagsoup.XMLWriter;
+
+/**
+ * 
+ */
+public class ConfluenceCleanupWriter extends XMLWriter {
+    private final Page page;
+    private final SiteExporter exporter;
+
+    public ConfluenceCleanupWriter(SiteExporter exp, Writer writer, Page page) {
+        super(writer);
+        this.page = page;
+        this.exporter = exp;
+    }
+
+    public void startElement(String uri, String localName, String qName, final Attributes atts)
+        throws SAXException {
+        Attributes newAtts = atts;
+        if ("a".equals(localName.toLowerCase())
+            || "a".equals(qName.toLowerCase())) {
+            String href = atts.getValue("href");
+            if (href != null && href.startsWith("/confluence/display/")) {
+                String params = "";
+                if (href.indexOf('#') != -1) {
+                    params = href.substring(href.indexOf('#'));
+                    href = href.substring(0, href.indexOf('#'));
+                }
+                try {
+                    final Page p = exporter.findPageByURL(href);
+                    if (p != null) {
+                        newAtts = new AttributesWrapper("href", p.createFileName()
+                                                        + params, atts);
+                    } else {
+                        System.out.println("Could not find page for " + href 
+                                           + " linked from " + page.getTitle());
+                    }
+                } catch (Exception e) {
+                    throw new SAXException(e);
+                }
+            } else if (href != null && href.contains("/confluence/download/attachments")) {
+                href = href.substring(href.lastIndexOf("/"));
+                String dirName = page.createFileName();
+                dirName = dirName.substring(0, dirName.lastIndexOf(".")) + ".data";
+
+                newAtts = new AttributesWrapper("href", dirName + href, atts);
+            }
+        } else if ("img".equals(localName.toLowerCase())
+            || "img".equals(qName.toLowerCase())) {
+            String href = atts.getValue("src");
+            if (href != null && href.startsWith("/confluence/images/")) {
+                newAtts = new AttributesWrapper("src", SiteExporter.HOST + href, atts);
+            } else if (href != null && href.startsWith("/confluence/download/attachments")) {
+                href = href.substring(0, href.lastIndexOf('?'));
+                href = href.substring(href.lastIndexOf('/'));
+                String dirName = page.createFileName();
+                dirName = dirName.substring(0, dirName.lastIndexOf(".")) + ".data";
+
+                newAtts = new AttributesWrapper("src", dirName + href, atts);
+            } else if (href != null && href.startsWith("/confluence/download/thumbnails")) {
+                
+                try {
+                    exporter.loadThumbnail(page, href);
+                } catch (Exception ex) {
+                    throw new SAXException(ex);
+                }
+                if (href.indexOf('?') != -1) {
+                    href = href.substring(0, href.lastIndexOf('?'));
+                }
+                href = href.substring(href.lastIndexOf('/'));
+                String dirName = page.createFileName();
+                dirName = dirName.substring(0, dirName.lastIndexOf(".")) + ".thumbs";
+
+                newAtts = new AttributesWrapper("src", dirName + href, atts);
+            }
+        }
+        super.startElement(uri, localName, qName, newAtts);
+    }
+    
+    
+
+
+    private final class AttributesWrapper implements Attributes {
+        private final Attributes atts;
+        private final String attr;
+        private final String newval;
+
+        private AttributesWrapper(String attr, String newval, Attributes atts) {
+            this.attr = attr;
+            this.newval = newval;
+            this.atts = atts;
+        }
+
+        public int getLength() {
+            return atts.getLength();
+        }
+
+        public String getURI(int index) {
+            return atts.getURI(index);
+        }
+
+        public String getLocalName(int index) {
+            return atts.getLocalName(index);
+        }
+
+        public String getQName(int index) {
+            return atts.getQName(index);
+        }
+
+        public String getType(int index) {
+            return atts.getType(index);
+        }
+
+        public int getIndex(String uri, String localName) {
+            return atts.getIndex(uri, localName);
+        }
+
+        public int getIndex(String qName) {
+            return atts.getIndex(qName);
+        }
+
+        public String getType(String uri, String localName) {
+            return atts.getType(uri, localName);
+        }
+
+        public String getType(String qName) {
+            return atts.getType(qName);
+        }
+
+        public String getValue(int index) {
+            if (index == getIndex(attr)) {
+                return getValue(attr);
+            }
+            return atts.getValue(index);
+        }
+
+        public String getValue(String uri, String localName) {
+            if (attr.equals(localName.toLowerCase())) {
+                return newval;
+            }
+            return atts.getValue(uri, localName);
+        }
+
+        public String getValue(String qName) {
+            if (attr.equals(qName.toLowerCase())) {
+                return newval;
+            }
+            return atts.getValue(qName);
+        }
+    }
+
+}

Propchange: cxf/web/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/web/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java
URL: http://svn.apache.org/viewvc/cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java?rev=1065833&view=auto
==============================================================================
--- cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java (added)
+++ cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java Mon Jan 31 22:17:46 2011
@@ -0,0 +1,113 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.cwiki;
+
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.w3c.dom.Document;
+
+import org.apache.cxf.helpers.DOMUtils;
+
+/**
+ * 
+ */
+public class Page implements Serializable {
+    XMLGregorianCalendar modified;
+    final String id;
+    final String parent;
+    final String title;
+    final String url;
+    Map<String, String> attachments;
+    
+    transient String content;
+    
+    public Page(Document doc) throws Exception {
+        id = DOMUtils.getChildContent(doc.getDocumentElement().getFirstChild(), "id");
+        parent = DOMUtils.getChildContent(doc.getDocumentElement().getFirstChild(), "parentId");
+        title = DOMUtils.getChildContent(doc.getDocumentElement().getFirstChild(), "title");
+        url = DOMUtils.getChildContent(doc.getDocumentElement().getFirstChild(), "url");
+        String mod = DOMUtils.getChildContent(doc.getDocumentElement().getFirstChild(), "modified");
+        modified = DatatypeFactory.newInstance().newXMLGregorianCalendar(mod);
+    }
+    
+    public String getId() {
+        return id;
+    }
+    public String getParentId() {
+        return parent;
+    }
+    public String getTitle() {
+        return title;
+    }
+    public XMLGregorianCalendar getModifiedTime() {
+        return modified;
+    }
+
+    public void setContent(String c) {
+        content = c;
+    }
+    public String getContent() {
+        return content;
+    }
+    public String getURL() {
+        return url;
+    }
+    
+    public String createFileName() {
+        StringBuffer buffer = new StringBuffer();
+        char array[] = getTitle().toLowerCase().toCharArray();
+        boolean separated = true;
+        for (int x = 0; x < array.length; x++) {
+            if ("abcdefghijklmnopqrstuvwxyz0123456789".indexOf(array[x]) >= 0) {
+                buffer.append(Character.toLowerCase(array[x]));
+                separated = false;
+            } else if ("\r\n\t -".indexOf(array[x]) >= 0) {
+                if (separated) {
+                    continue;
+                }
+                buffer.append('-');
+                separated = true;
+            }
+        }
+        if (buffer.length() == 0) {
+            return getId() + ".html";
+        }
+        return buffer.append(".html").toString();
+    }
+
+    public void addAttachment(String aid, String filename) {
+        if (attachments == null) {
+            attachments = new HashMap<String, String>();
+        }
+        attachments.put(aid, filename);
+    }
+    public String getAttachmentFilename(String aid) {
+        if (attachments == null) {
+            return null;
+        }
+        return attachments.get(aid);
+    }
+}

Propchange: cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 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=1065833&view=auto
==============================================================================
--- cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java (added)
+++ cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java Mon Jan 31 22:17:46 2011
@@ -0,0 +1,449 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.cwiki;
+
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPBinding;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.Velocity;
+import org.ccil.cowan.tagsoup.Parser;
+import org.ccil.cowan.tagsoup.XMLWriter;
+
+/**
+ * 
+ */
+public class SiteExporter {
+
+    static final String HOST = "https://cwiki.apache.org";
+    static final String ROOT = HOST + "/confluence";
+    static final String RPC_ROOT = "/rpc/soap-axis/confluenceservice-v1";
+
+    
+    static final String SOAPNS = "http://soap.rpc.confluence.atlassian.com";
+
+    static final Set<String> GLOBAL_PAGES = new HashSet<String>();
+    static {
+        GLOBAL_PAGES.add("Navigation");
+        GLOBAL_PAGES.add("Banner");
+        GLOBAL_PAGES.add("QuickLinks");        
+    }
+    
+    
+
+    Dispatch<Document> dispatch;
+    Map<String, Page> pages = new HashMap<String, Page>();
+    List<Page> modifiedPages = new LinkedList<Page>();
+    
+    String userName = "cxf-export-user";
+    String password = "autoexport-cxf";
+    String spaceKey = "CXF";
+    String pageCacheFile = "pagesConfig.obj";
+    
+    File outputDir = new File(".");
+
+    String loginToken;
+    Template template;
+    
+    public SiteExporter(List<String> args) throws Exception {
+        
+        Service service = Service.create(new QName(SOAPNS, "Service"));
+        service.addPort(new QName(SOAPNS, "Port"), 
+                        SOAPBinding.SOAP11HTTP_BINDING,
+                        ROOT + RPC_ROOT);
+
+        dispatch = service.createDispatch(new QName(SOAPNS, "Port"), 
+                                          Document.class, Service.Mode.PAYLOAD);
+        
+        ListIterator<String> it = args.listIterator();
+        while (it.hasNext()) {
+            String s = it.next();
+            if ("-debug".equals(s)) {
+                ((org.apache.cxf.jaxws.DispatchImpl)dispatch).getClient()
+                    .getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
+                ((org.apache.cxf.jaxws.DispatchImpl)dispatch).getClient()
+                    .getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
+            } else if ("-d".equals(s)) {
+                outputDir = new File(it.next());
+            } else if ("-user".equals(s)) {
+                userName = it.next(); 
+            } else if ("-password".equals(s)) {
+                password = it.next(); 
+            } else if ("-space".equals(s)) {
+                spaceKey = it.next(); 
+            } else if ("-cache".equals(s)) {
+                pageCacheFile = it.next();
+            }
+        }
+        
+        Properties props = new Properties();
+        String clzName = "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader";
+        props.put("resource.loader", "class");
+        props.put("class.resource.loader.class", clzName);
+        Velocity.init(props);
+
+        template = Velocity.getTemplate("template.vm");
+        outputDir.mkdirs();
+    }
+    
+    public void run() throws Exception {
+        doLogin();
+        loadPages();
+        
+        for (Page p : modifiedPages) {
+            if (GLOBAL_PAGES.contains(p.getTitle())) {
+                modifiedPages = new LinkedList<Page>(pages.values());
+                break;
+            }
+        }
+        /*
+        // debug stuff, force regen of a page
+        modifiedPages.add(findPage("Setting up Eclipse for Running and Debugging Distributed OSGi"));
+        modifiedPages.add(findPage("Apache CXF 2.3.2 Release Notes"));
+        modifiedPages.add(findPage("FAQ"));
+        modifiedPages.add(findPage("Apache CXF 2.1.3 Release Notes"));
+        */
+        
+        renderPages();
+        savePages();
+    }
+
+    private void savePages() throws Exception {
+        File file = new File(pageCacheFile);
+        file.getParentFile().mkdirs();
+        FileOutputStream fout = new FileOutputStream(file);
+        ObjectOutputStream oout = new ObjectOutputStream(fout);
+        oout.writeObject(pages);
+        oout.close();
+    }
+
+    private void renderPages() throws Exception {
+        int total = modifiedPages.size();
+        int count = 0;
+        for (Page p : modifiedPages) {
+            count++;
+            System.out.println("Rendering " + p.getTitle() + "    (" + count + "/" + total + ")");
+            loadAttachments(p);
+            
+            loadPageContent(p);
+            VelocityContext ctx = new VelocityContext();
+            ctx.put("exporter", this);
+            ctx.put("page", p);
+            ctx.put("confluenceUri", ROOT);
+            FileWriter writer = new FileWriter(new File(outputDir, p.createFileName()));
+            ctx.put("out", writer);
+            template.merge(ctx, writer);
+            writer.close();
+        }
+    }
+
+    
+    private void loadAttachments(Page p) throws Exception {
+        Document doc = XMLUtils.newDocument();
+        Element el = doc.createElementNS(SOAPNS, "ns1:getAttachments");
+        Element el2 = doc.createElement("in0");
+        el.appendChild(el2);
+        el2.setTextContent(loginToken);
+        el2 = doc.createElement("in1");
+        el.appendChild(el2);
+        el2.setTextContent(p.getId());
+        el.appendChild(el2);
+        doc.appendChild(el);
+
+        doc = dispatch.invoke(doc);
+        el = DOMUtils.getFirstElement(DOMUtils.getFirstElement(doc.getDocumentElement()));
+        while (el != null) {
+            String filename = DOMUtils.getChildContent(el, "fileName");
+            String durl = DOMUtils.getChildContent(el, "url");
+            String aid = DOMUtils.getChildContent(el, "id");
+            
+            p.addAttachment(aid, filename);
+            
+            String dirName = p.createFileName();
+            dirName = dirName.substring(0, dirName.lastIndexOf(".")) + ".data";
+            File file = new File(outputDir, dirName);
+            file.mkdirs();
+            file = new File(file, filename);
+            FileOutputStream out = new FileOutputStream(file);
+            URL url = new URL(durl);
+            InputStream ins = url.openStream();
+            IOUtils.copy(ins, out);
+            out.close();
+            ins.close();
+            el = DOMUtils.getNextElement(el);
+        }
+    }
+    void loadThumbnail(Page p, String href) throws Exception {
+        String filename = href.substring(href.lastIndexOf('/') + 1);
+        
+        String dirName = p.createFileName();
+        dirName = dirName.substring(0, dirName.lastIndexOf(".")) + ".thumbs";
+        File file = new File(outputDir, dirName);
+        file.mkdirs();
+        file = new File(file, filename);
+        FileOutputStream out = new FileOutputStream(file);
+        URL url = new URL(HOST + href);
+        InputStream ins = url.openStream();
+        IOUtils.copy(ins, out);
+        out.close();
+        ins.close();
+    }
+    public Page findPage(String title) throws Exception {
+        for (Page p : pages.values()) {
+            if (title.equals(p.getTitle())) {
+                return p;
+            }
+        }
+        return null;
+    }
+    public Page findPageByURL(String url) throws Exception {
+        for (Page p : pages.values()) {
+            if (p.getURL().endsWith(url)) {
+                return p;
+            }
+        }
+        return null;
+    }
+    
+    public String breadcrumbs(Page page) {
+        String separator = "&gt;";
+        String s = "&nbsp;" + separator + "&nbsp;";
+
+        StringBuffer buffer = new StringBuffer();
+        List<Page> p = new LinkedList<Page>();
+        String parentId = page.getParentId();
+        Page parent = pages.get(parentId);
+        while (parent != null) {
+            p.add(0, parent);
+            parentId = parent.getParentId();
+            parent = pages.get(parentId);
+        }
+        for (Page p2 : p) {
+            buffer.append("<a href=\"");
+            buffer.append(p2.createFileName());
+            buffer.append("\">");
+            buffer.append(p2.getTitle());
+            buffer.append("</a>");
+            buffer.append(s);
+        }
+        buffer.append("<a href=\"");
+        buffer.append(page.createFileName());
+        buffer.append("\">");
+        buffer.append(page.getTitle());
+        buffer.append("</a>");
+
+        return buffer.toString();
+    }
+    
+    public String getPageContent(String title) throws Exception {
+        Page p = findPage(title);
+        String s = p.getContent();
+        if (s == null) {
+            loadPageContent(p);
+        }
+        return p.getContent();
+    }
+    private void loadPageContent(Page p) throws Exception {
+        Document doc = XMLUtils.newDocument();
+        Element el = doc.createElementNS(SOAPNS, "ns1:renderContent");
+        Element el2 = doc.createElement("in0");
+        el.appendChild(el2);
+        el2.setTextContent(loginToken);
+        el2 = doc.createElement("in1");
+        el.appendChild(el2);
+        el2.setTextContent(spaceKey);
+        
+        el2 = doc.createElement("in2");
+        el.appendChild(el2);
+        el2.setTextContent(p.getId());
+
+        el2 = doc.createElement("in3");
+        el.appendChild(el2);
+
+        el2 = doc.createElement("in4");  //apachesoap map
+        el.appendChild(el2);
+
+        Element el4 = doc.createElement("item");
+        el2.appendChild(el4);
+        
+        Element el3 = doc.createElement("key");
+        el3.setTextContent("style");
+        el4.appendChild(el3);
+        el3 = doc.createElement("value");
+        el3.setTextContent("clean");
+        el4.appendChild(el3);
+
+        
+        doc.appendChild(el);
+        doc = dispatch.invoke(doc);
+        
+        String content = doc.getDocumentElement().getFirstChild().getTextContent().trim();
+        
+        p.setContent(updateContentLinks(p, content));
+    }
+
+    
+    private void doLogin() throws Exception {
+        Document doc = XMLUtils.newDocument();
+        Element el = doc.createElementNS(SOAPNS, "ns1:login");
+        Element el2 = doc.createElement("in0");
+        
+        if (userName == null) {
+            System.out.println("Enter username: ");
+            el2.setTextContent(System.console().readLine());
+        } else {
+            el2.setTextContent(userName);
+        }
+        el.appendChild(el2);
+        el2 = doc.createElement("in1");
+        el.appendChild(el2);
+        if (password == null) {
+            System.out.println("Enter password: ");
+            el2.setTextContent(new String(System.console().readPassword()));
+        } else {
+            el2.setTextContent(password);
+        }
+        doc.appendChild(el);
+        doc = dispatch.invoke(doc);
+        loginToken = doc.getDocumentElement().getFirstChild().getTextContent();
+    }
+
+    @SuppressWarnings("unchecked")
+    public void loadPages() throws Exception {
+        File file = new File(pageCacheFile);
+        if (file.exists()) {
+            FileInputStream fin = new FileInputStream(pageCacheFile);
+            ObjectInputStream oin = new ObjectInputStream(fin);
+            pages = (Map)oin.readObject();
+            oin.close();
+        }
+        
+        Document doc = XMLUtils.newDocument();
+        Element el = doc.createElementNS(SOAPNS, "ns1:getPages");
+        Element el2 = doc.createElement("in0");
+        el.appendChild(el2);
+        el2.setTextContent(loginToken);
+        el2 = doc.createElement("in1");
+        el.appendChild(el2);
+        el2.setTextContent(spaceKey);
+        doc.appendChild(el);
+        doc = dispatch.invoke(doc);
+        
+        Node nd = doc.getDocumentElement().getFirstChild().getFirstChild();
+        while (nd != null) {
+            if (nd instanceof Element) {
+                loadPage((Element)nd);
+            }
+            nd = nd.getNextSibling();
+        }
+    }
+    public void loadPage(Element pageSumEl) throws Exception {
+        Document doc = XMLUtils.newDocument();
+        Element el = doc.createElementNS(SOAPNS, "ns1:getPage");
+        Element el2 = doc.createElement("in0");
+        el.appendChild(el2);
+        el2.setTextContent(loginToken);
+        el2 = doc.createElement("in1");
+        el.appendChild(el2);
+        el2.setTextContent(DOMUtils.getChildContent(pageSumEl, "id"));
+        doc.appendChild(el);
+        doc = dispatch.invoke(doc);
+        
+        Page page = new Page(doc);
+        Page oldPage = pages.get(page.getId());
+        if (oldPage == null || page.getModifiedTime().compare(oldPage.getModifiedTime()) > 0) {
+            modifiedPages.add(page);
+            pages.put(page.getId(), page);
+        }
+    }    
+    
+    private String updateContentLinks(Page page, String content) throws Exception {
+        XMLReader parser = createTagSoupParser();
+        StringWriter w = new StringWriter();
+        parser.setContentHandler(createContentHandler(page, w));
+        parser.parse(new InputSource(new StringReader(content)));
+        content = w.toString();
+        content = content.substring("<html><body>".length());
+        content = content.substring(0, content.lastIndexOf("</body></html>"));
+        return content;
+    }
+    protected XMLReader createTagSoupParser() throws Exception {
+        XMLReader reader = new Parser();
+        reader.setFeature(Parser.namespacesFeature, false);
+        reader.setFeature(Parser.namespacePrefixesFeature, false);
+        reader.setProperty(Parser.schemaProperty, new org.ccil.cowan.tagsoup.HTMLSchema() {
+            {
+                //problem with nested lists that the confluence {toc} macro creates
+                elementType("ul", M_LI, M_BLOCK | M_LI, 0);
+            }
+        });
+
+        return reader;
+    }
+    protected ContentHandler createContentHandler(final Page page, Writer w) {
+        XMLWriter xmlWriter = new ConfluenceCleanupWriter(this, w, page);
+        xmlWriter.setOutputProperty(XMLWriter.OMIT_XML_DECLARATION, "yes");
+        xmlWriter.setOutputProperty(XMLWriter.METHOD, "html");
+        return xmlWriter;
+    }
+
+    public static void main(String[] args) throws Exception {
+        new SiteExporter(Arrays.asList(args)).run();
+    }
+
+}

Propchange: cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/web/src/main/resources/template.vm
URL: http://svn.apache.org/viewvc/cxf/web/src/main/resources/template.vm?rev=1065833&view=auto
==============================================================================
--- cxf/web/src/main/resources/template.vm (added)
+++ cxf/web/src/main/resources/template.vm Mon Jan 31 22:17:46 2011
@@ -0,0 +1,146 @@
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<html>
+  <head>
+    <link type="text/css" rel="stylesheet" href="http://cxf.apache.org/resources/site.css"></link>
+    <script src="http://cxf.apache.org/resources/space.js" type="text/javascript"></script>
+
+<meta name="keywords" content="business integration, EAI, SOA, Service Oriented Architecture, web services, SOAP, JBI, JMS, WSDL, XML, EDI, Electronic Data Interchange, standards support, integration standards, application integration, middleware, software, solutions, services, CXF, open source"/>
+<meta name="description" content"Apache CXF, Services Framework - $page.title" />
+    <title>
+Apache CXF -- $page.title
+    </title>
+  </head>
+<body onload="init()">
+
+
+<table width="100%" cellpadding="0" cellspacing="0">
+  <tr width="100%">
+    <td id="cell-0-0" colspan="2">&nbsp;</td>
+    <td id="cell-0-1">&nbsp;</td>
+    <td id="cell-0-2" colspan="2">&nbsp;</td>
+  </tr>
+  <tr width="100%">
+    <td id="cell-1-0">&nbsp;</td>
+    <td id="cell-1-1">&nbsp;</td>
+    <td id="cell-1-2">
+      <div style="padding: 5px;">
+        <div id="banner">
+          <!-- Banner -->
+#set($content = $exporter.getPageContent("Banner"))
+$content
+          <!-- Banner -->
+        </div>
+      </div>
+      <div id="top-menu">
+        <table border="0" cellpadding="1" cellspacing="0" width="100%">
+          <tr>
+            <td>
+              <div align="left">
+                <!-- Breadcrumbs -->
+#set($content = $exporter.breadcrumbs($page))
+$content
+                <!-- Breadcrumbs -->
+              </div>
+            </td>
+            <td>
+              <div align="right">
+                <!-- Quicklinks -->
+#set($content = $exporter.getPageContent("QuickLinks"))
+$content
+                <!-- Quicklinks -->
+              </div>
+            </td>
+          </tr>
+        </table>
+      </div>
+    </td>
+    <td id="cell-1-3">&nbsp;</td>
+    <td id="cell-1-4">&nbsp;</td>
+  </tr>
+  <tr width="100%">
+    <td id="cell-2-0" colspan="2">&nbsp;</td>
+    <td id="cell-2-1">
+      <table>
+        <tr height="100%" valign="top">
+          <td height="100%">
+            <div id="wrapper-menu-page-right">
+              <div id="wrapper-menu-page-top">
+                <div id="wrapper-menu-page-bottom">
+                  <div id="menu-page">
+                    <!-- NavigationBar -->
+#set($content = $exporter.getPageContent("Navigation"))
+$content
+                    <!-- NavigationBar -->
+                  </div>
+              </div>
+            </div>
+          </div>
+         </td>
+         <td height="100%">
+           <!-- Content -->
+           <div class="wiki-content">
+#set($content = $page.getContent())
+$content
+           </div>
+           <!-- Content -->
+         </td>
+        </tr>
+      </table>
+   </td>
+   <td id="cell-2-2" colspan="2">&nbsp;</td>
+  </tr>
+  <tr width="100%">
+   <td id="cell-3-0">&nbsp;</td>
+   <td id="cell-3-1">&nbsp;</td>
+   <td id="cell-3-2">
+     <div id="footer">
+       <!-- Footer -->
+       <div id="site-footer">
+         <a href="http://cxf.apache.org/privacy-policy.html">Privacy Policy</a> - 
+         (<a href="$confluenceUri/pages/editpage.action?pageId=$page.id">edit page</a>) 
+	 (<a href="$page.getURL()?showComments=true&showCommentArea=true#addcomment">add comment</a>)
+       </div>
+       <!-- Footer -->
+     </div>
+   </td>
+   <td id="cell-3-3">&nbsp;</td>
+   <td id="cell-3-4">&nbsp;</td>
+  </tr>
+  <tr width="100%">
+    <td id="cell-4-0" colspan="2">&nbsp;</td>
+    <td id="cell-4-1">&nbsp;</td>
+    <td id="cell-4-2" colspan="2">&nbsp;</td>
+  </tr>
+</table>
+
+<script type="text/javascript">
+var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+</script>
+<script type="text/javascript">
+try {
+var pageTracker = _gat._getTracker("UA-4458903-1");
+pageTracker._trackPageview();
+} catch(err) {}</script>
+
+</body>
+</html>
+