Author: bdudney
Date: Sat Oct 21 03:42:48 2006
New Revision: 466374

URL: http://svn.apache.org/viewvc?view=rev&rev=466374
Log:
moving the tutorials

Added:
    incubator/cayenne/main/trunk/tutorials/
      - copied from r465759, incubator/cayenne/main/trunk/pre-maven/tutorials/
Removed:
    incubator/cayenne/main/trunk/pre-maven/tutorials/
Modified:
    
incubator/cayenne/main/trunk/other/cayenne-build-tools/src/main/java/org/apache/cayenne/tools/ant/docgen/DocGenerator.java
    
incubator/cayenne/main/trunk/other/confluence-maven-plugin/src/test/java/org/apache/cayenne/other/plugin/confluence/ConfluenceExportMojoTest.java
    incubator/cayenne/main/trunk/pom.xml
    
incubator/cayenne/main/trunk/tutorials/quick-start-rop/cayenne-tutorial-client/.project
    
incubator/cayenne/main/trunk/tutorials/quick-start-rop/cayenne-tutorial/.project

Modified: 
incubator/cayenne/main/trunk/other/cayenne-build-tools/src/main/java/org/apache/cayenne/tools/ant/docgen/DocGenerator.java
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/other/cayenne-build-tools/src/main/java/org/apache/cayenne/tools/ant/docgen/DocGenerator.java?view=diff&rev=466374&r1=466373&r2=466374
==============================================================================
--- 
incubator/cayenne/main/trunk/other/cayenne-build-tools/src/main/java/org/apache/cayenne/tools/ant/docgen/DocGenerator.java
 (original)
+++ 
incubator/cayenne/main/trunk/other/cayenne-build-tools/src/main/java/org/apache/cayenne/tools/ant/docgen/DocGenerator.java
 Sat Oct 21 03:42:48 2006
@@ -22,6 +22,8 @@
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.FileWriter;
+import java.io.InputStream;
+import java.net.URL;
 import java.util.Iterator;
 
 import 
org.objectstyle.confluence.rpc.soap_axis.confluenceservice_v1.ConfluenceSoapService;
@@ -37,158 +39,187 @@
  * @author Cris Daniluk
  */
 public class DocGenerator {
-
-    private static final String DEFAULT_TEMPLATE = "doctemplates/default.vm";
-    private static final String ENDPOINT_SUFFIX = 
"/rpc/soap-axis/confluenceservice-v1";
-    private String baseUrl;
-    private String spaceKey;
-    private String docBase;
-    private String startPage;
-
-    private String token;
-    private ConfluenceSoapService service;
-
-    private String username;
-    private String password;
-
-    private String template;
-
-    private DocPageRenderer parser;
-
-    public DocGenerator(String baseUrl, String spaceKey, String docBase,
-            String startPage, String username, String password, String 
template) {
-
-        ConfluenceSoapServiceProxy service = new ConfluenceSoapServiceProxy();
-
-        // derive service URL from base URL
-        if (baseUrl != null) {
-            if (baseUrl.endsWith("/")) {
-                baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
-            }
-
-            String endpoint = baseUrl + ENDPOINT_SUFFIX;
-            service.setEndpoint(endpoint);
-        }
-        // service base URL from service default URL
-        else if (service.getEndpoint().endsWith(ENDPOINT_SUFFIX)) {
-            String endpoint = service.getEndpoint();
-            baseUrl = endpoint.substring(0, endpoint.length() - 
ENDPOINT_SUFFIX.length());
-        }
-        else {
-            throw new IllegalArgumentException("Null base url and invalid 
service URL");
-        }
-
-        this.baseUrl = baseUrl;
-        this.service = service;
-        this.spaceKey = spaceKey;
-        this.docBase = docBase;
-        this.startPage = startPage;
-        this.username = username;
-        this.password = password;
-
-        if (template == null) {
-            this.template = DEFAULT_TEMPLATE;
-        }
-        else {
-            this.template = template;
-        }
-    }
-
-    public void generateDocs() throws Exception {
-
-        login();
-
-               // only works for adminstrators
-        //String url = service.exportSite(token, true);
-
-               //URL foo = new URL(url);
-        createPath(docBase);
-
-        // Build a page hierarchy first..
-        DocPage page = getPage(null, startPage);
-
-        iterateChildren(page);
-
-        // Now render the content nodes..
-        renderPage(page, docBase);
-
-    }
-
-    protected void iterateChildren(DocPage parent) throws Exception {
-
-        RemotePageSummary[] children = getChildren(parent);
-        for (int i = 0; i < children.length; i++) {
-
-            DocPage child = getPage(parent, children[i].getTitle());
-            parent.addChild(child);
-            iterateChildren(child);
-
-        }
-
-    }
-
-    protected void renderPage(DocPage page, String basePath) throws Exception {
-        String currentPath = basePath + "/" + page.getTitle();
-
-        createPath(currentPath);
-
-        FileWriter fw = new FileWriter(currentPath + "/index.html");
-        parser.render(page, fw);
-        fw.close();
-
-        writeAttachments(currentPath, page);
-
-        for (Iterator childIter = page.getChildren().iterator(); 
childIter.hasNext();) {
-            renderPage((DocPage) childIter.next(), currentPath);
-        }
-
-    }
-
-    protected RemotePageSummary[] getChildren(DocPage page) throws Exception {
-        return service.getChildren(token, page.getId());
-    }
-
-    protected void writeAttachments(String basePath, DocPage page) throws 
Exception {
-        RemoteAttachment[] attachments = service.getAttachments(token, 
page.getId());
-
-        for (int j = 0; j < attachments.length; j++) {
-
-            FileOutputStream fos = null;
-            try {
-                fos = new FileOutputStream(basePath + "/" + 
attachments[j].getFileName());
-
-                fos.write(getAttachmentData(page, attachments[j]));
-            }
-            finally {
-                fos.close();
-            }
-
-        }
-    }
-
-    protected byte[] getAttachmentData(DocPage page, RemoteAttachment 
attachment)
-            throws Exception {
-        return service
-                .getAttachmentData(token, page.getId(), 
attachment.getFileName(), 0);
-    }
-
-    protected void login() throws Exception {
-        token = service.login(username, password);
-        parser = new DocPageRenderer(service, baseUrl, token, spaceKey, 
template);
-    }
-
-    protected DocPage getPage(DocPage parentPage, String pageTitle) throws 
Exception {
-        RemotePage page = service.getPage(token, spaceKey, pageTitle);
-        return new DocPage(parentPage, page.getTitle(), page.getId(), 
page.getContent());
-    }
-
-    protected void createPath(String path) {
-        new File(path).mkdirs();
-
-    }
-
-    public String getBaseUrl() {
-        return baseUrl;
-    }
+       private static final String DEFAULT_TEMPLATE = 
"doctemplates/default.vm";
+       private static final String ENDPOINT_SUFFIX = 
"/rpc/soap-axis/confluenceservice-v1";
+       private String baseUrl;
+       private String spaceKey;
+       private String docBase;
+       private String startPage;
+       private String token;
+       private ConfluenceSoapService service;
+       private String username;
+       private String password;
+       private String template;
+       private DocPageRenderer parser;
+
+       public DocGenerator(String baseUrl, String spaceKey, String docBase,
+                       String startPage, String username, String password, 
String template) {
+
+               ConfluenceSoapServiceProxy service = new 
ConfluenceSoapServiceProxy();
+
+               // derive service URL from base URL
+               if (baseUrl != null) {
+                       if (baseUrl.endsWith("/")) {
+                               baseUrl = baseUrl.substring(0, baseUrl.length() 
- 1);
+                       }
+
+                       String endpoint = baseUrl + ENDPOINT_SUFFIX;
+                       service.setEndpoint(endpoint);
+               }
+               // service base URL from service default URL
+               else if (service.getEndpoint().endsWith(ENDPOINT_SUFFIX)) {
+                       String endpoint = service.getEndpoint();
+                       baseUrl = endpoint.substring(0, endpoint.length()
+                                       - ENDPOINT_SUFFIX.length());
+               } else {
+                       throw new IllegalArgumentException(
+                                       "Null base url and invalid service 
URL");
+               }
+
+               this.baseUrl = baseUrl;
+               this.service = service;
+               this.spaceKey = spaceKey;
+               this.docBase = docBase;
+               this.startPage = startPage;
+               this.username = username;
+               this.password = password;
+
+               if (template == null) {
+                       this.template = DEFAULT_TEMPLATE;
+               } else {
+                       this.template = template;
+               }
+       }
+
+       public void generateDocs() throws Exception {
+
+               login();
+
+               // only works for adminstrators
+               InputStream stream = null;
+               FileOutputStream output = null;
+               try {
+                       String inputURL = service.exportSpace(token, spaceKey, 
"TYPE_HTML");
+                       URL url = new URL(inputURL);
+                       System.out.println("url = " + url);
+                       // get the data
+                       stream = url.openStream();
+                       File outputDirectory = new File(docBase);
+                       if (!outputDirectory.exists()) {
+                               if (!outputDirectory.mkdir()) {
+                                       throw new Exception("Unable to make the 
directory "
+                                                       + 
outputDirectory.getCanonicalPath());
+                               }
+                       }
+                       File outputFile = new 
File(outputDirectory.getCanonicalFile() + File.pathSeparator + 
"ExportedDocumentation");
+                       output = new FileOutputStream(outputFile);
+                       byte data[] = new byte[1024];
+                       int amtRead = stream.read(data);
+                       while(amtRead != -1) {
+                               output.write(data, 0, amtRead);
+                               amtRead = stream.read(data);
+                       }
+                       output.flush();
+                       output.close();
+                       stream.close();
+               } finally {
+                       if(stream != null) stream.close();
+                       if(output != null) output.close();
+               }
+               // the old cayenne approach that works but is very slow
+               // createPath(docBase);
+               //
+               // // Build a page hierarchy first..
+               // DocPage page = getPage(null, startPage);
+               //
+               // iterateChildren(page);
+               //
+               // // Now render the content nodes..
+               // renderPage(page, docBase);
+
+       }
+
+       protected void iterateChildren(DocPage parent) throws Exception {
+
+               RemotePageSummary[] children = getChildren(parent);
+               for (int i = 0; i < children.length; i++) {
+
+                       DocPage child = getPage(parent, children[i].getTitle());
+                       parent.addChild(child);
+                       iterateChildren(child);
+
+               }
+
+       }
+
+       protected void renderPage(DocPage page, String basePath) throws 
Exception {
+               String currentPath = basePath + "/" + page.getTitle();
+
+               createPath(currentPath);
+
+               FileWriter fw = new FileWriter(currentPath + "/index.html");
+               parser.render(page, fw);
+               fw.close();
+
+               writeAttachments(currentPath, page);
+
+               for (Iterator childIter = page.getChildren().iterator(); 
childIter
+                               .hasNext();) {
+                       renderPage((DocPage) childIter.next(), currentPath);
+               }
+
+       }
+
+       protected RemotePageSummary[] getChildren(DocPage page) throws 
Exception {
+               return service.getChildren(token, page.getId());
+       }
+
+       protected void writeAttachments(String basePath, DocPage page)
+                       throws Exception {
+               RemoteAttachment[] attachments = service.getAttachments(token, 
page
+                               .getId());
+
+               for (int j = 0; j < attachments.length; j++) {
+
+                       FileOutputStream fos = null;
+                       try {
+                               fos = new FileOutputStream(basePath + "/"
+                                               + attachments[j].getFileName());
+
+                               fos.write(getAttachmentData(page, 
attachments[j]));
+                       } finally {
+                               fos.close();
+                       }
+
+               }
+       }
+
+       protected byte[] getAttachmentData(DocPage page, RemoteAttachment 
attachment)
+                       throws Exception {
+               return service.getAttachmentData(token, page.getId(), attachment
+                               .getFileName(), 0);
+       }
+
+       protected void login() throws Exception {
+               token = service.login(username, password);
+               parser = new DocPageRenderer(service, baseUrl, token, spaceKey,
+                               template);
+       }
+
+       protected DocPage getPage(DocPage parentPage, String pageTitle)
+                       throws Exception {
+               RemotePage page = service.getPage(token, spaceKey, pageTitle);
+               return new DocPage(parentPage, page.getTitle(), page.getId(), 
page
+                               .getContent());
+       }
+
+       protected void createPath(String path) {
+               new File(path).mkdirs();
+
+       }
+
+       public String getBaseUrl() {
+               return baseUrl;
+       }
 
 }

Modified: 
incubator/cayenne/main/trunk/other/confluence-maven-plugin/src/test/java/org/apache/cayenne/other/plugin/confluence/ConfluenceExportMojoTest.java
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/other/confluence-maven-plugin/src/test/java/org/apache/cayenne/other/plugin/confluence/ConfluenceExportMojoTest.java?view=diff&rev=466374&r1=466373&r2=466374
==============================================================================
--- 
incubator/cayenne/main/trunk/other/confluence-maven-plugin/src/test/java/org/apache/cayenne/other/plugin/confluence/ConfluenceExportMojoTest.java
 (original)
+++ 
incubator/cayenne/main/trunk/other/confluence-maven-plugin/src/test/java/org/apache/cayenne/other/plugin/confluence/ConfluenceExportMojoTest.java
 Sat Oct 21 03:42:48 2006
@@ -1,5 +1,7 @@
 package org.apache.cayenne.other.plugin.confluence;
 
+import java.net.URL;
+
 import junit.framework.TestCase;
 
 public class ConfluenceExportMojoTest extends TestCase {
@@ -26,12 +28,11 @@
        public void testExecute() throws Exception {
                /*
                ConfluenceExportMojo mojo = new ConfluenceExportMojo();
-               mojo.setOutputDirectory("/tmp");
-               mojo.setPassword("your passwd here");
-               mojo.setUserName("your user id here");
+               mojo.setOutputDirectory("/tmp/teststuff");
+               mojo.setUserName("[EMAIL PROTECTED]");
+               mojo.setPassword("aust!n");
                mojo.setRootURL(new URL("http://cwiki.apache.org/confluence";));
-               mojo.setSpaceName("CAYDOC");
-               mojo.setStartPage("Documentation");
+               mojo.setSpaceName("CAY");
                mojo.execute();
                */
        }

Modified: incubator/cayenne/main/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/pom.xml?view=diff&rev=466374&r1=466373&r2=466374
==============================================================================
--- incubator/cayenne/main/trunk/pom.xml (original)
+++ incubator/cayenne/main/trunk/pom.xml Sat Oct 21 03:42:48 2006
@@ -39,6 +39,7 @@
                <module>modeler</module>
                <module>integration-test</module>
                <module>other</module>
+               <module>assembly</module>
        </modules>
 
        <issueManagement>

Modified: 
incubator/cayenne/main/trunk/tutorials/quick-start-rop/cayenne-tutorial-client/.project
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/tutorials/quick-start-rop/cayenne-tutorial-client/.project?view=diff&rev=466374&r1=465759&r2=466374
==============================================================================
--- 
incubator/cayenne/main/trunk/tutorials/quick-start-rop/cayenne-tutorial-client/.project
 (original)
+++ 
incubator/cayenne/main/trunk/tutorials/quick-start-rop/cayenne-tutorial-client/.project
 Sat Oct 21 03:42:48 2006
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-       <name>cayenne-tutorial-client</name>
+       <name>cayenne-rop-client-tutorial</name>
        <comment></comment>
        <projects>
        </projects>

Modified: 
incubator/cayenne/main/trunk/tutorials/quick-start-rop/cayenne-tutorial/.project
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/tutorials/quick-start-rop/cayenne-tutorial/.project?view=diff&rev=466374&r1=465759&r2=466374
==============================================================================
--- 
incubator/cayenne/main/trunk/tutorials/quick-start-rop/cayenne-tutorial/.project
 (original)
+++ 
incubator/cayenne/main/trunk/tutorials/quick-start-rop/cayenne-tutorial/.project
 Sat Oct 21 03:42:48 2006
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-       <name>cayenne-tutorial</name>
+       <name>cayenne-rop-server-tutorial</name>
        <comment></comment>
        <projects>
        </projects>


Reply via email to