You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ja...@apache.org on 2009/11/22 23:30:30 UTC

svn commit: r883162 - in /incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH: ChangeLog export.sh src/com/ecyrd/jspwiki/Release.java src/com/ecyrd/jspwiki/content/Exporter.java tests/com/ecyrd/jspwiki/content/ExporterTest.java

Author: jalkanen
Date: Sun Nov 22 22:30:29 2009
New Revision: 883162

URL: http://svn.apache.org/viewvc?rev=883162&view=rev
Log:
Reworked export routines; added sanity checks and disabled attachment exporting for now.
Added actual export shell script.

Added:
    incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/export.sh   (with props)
Modified:
    incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog
    incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java
    incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/content/Exporter.java
    incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/content/ExporterTest.java

Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog?rev=883162&r1=883161&r2=883162&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog Sun Nov 22 22:30:29 2009
@@ -1,3 +1,10 @@
+2008-04-04  Janne Jalkanen <ja...@apache.org>
+
+        * 2.8.4-svn-2
+        
+        * Added export script (export.sh); disabled attachment export for now to test
+        proper exporting.
+        
 2009-11-21 Harry Metske <me...@apache.org>
 
         * 2.8.4-svn-1

Added: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/export.sh
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/export.sh?rev=883162&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/export.sh (added)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/export.sh Sun Nov 22 22:30:29 2009
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# Create a classpath
+
+CP="build:tests/etc:etc/i18n:tests/lib/stripes-1.5.jar"
+
+for i in lib/*.jar
+do
+    CP=$i:${CP}
+done
+
+java -classpath $CP com.ecyrd.jspwiki.content.Exporter $@

Propchange: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/export.sh
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java?rev=883162&r1=883161&r2=883162&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java Sun Nov 22 22:30:29 2009
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "1";
+    public static final String     BUILD         = "2";
     
     /**
      *  This is the generic version string you should use

Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/content/Exporter.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/content/Exporter.java?rev=883162&r1=883161&r2=883162&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/content/Exporter.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/content/Exporter.java Sun Nov 22 22:30:29 2009
@@ -47,11 +47,15 @@
  *  name set in jspwiki.properties, and the name of the page.  This means
  *  that it is possible to get collisions, if you have two wikis with
  *  the same appname.
+ *  <p>
+ *  The exported WikiSpace name is always "main".  You can edit the XML
+ *  file by hand if you wish to import it to a different wikispace.
  */
 public class Exporter
 {
     private WikiEngine m_engine;
     private PrintWriter m_out;
+    private boolean     m_verbose = false;
     
     private MimetypesFileTypeMap m_mimeTypes = new MimetypesFileTypeMap();
     
@@ -72,10 +76,11 @@
      * 
      *  @throws UnsupportedEncodingException If your platform does not support UTF-8
      */
-    public Exporter(WikiEngine engine, OutputStream outStream) throws UnsupportedEncodingException
+    public Exporter(WikiEngine engine, OutputStream outStream, boolean verbose) throws UnsupportedEncodingException
     {
         m_engine = engine;
         m_out = new PrintWriter( new OutputStreamWriter(outStream,"UTF-8") );
+        m_verbose = verbose;
     }
     
     /**
@@ -94,7 +99,7 @@
         
         m_out.println("<!--");
         m_out.println("This is an JSR-170 -compliant Document Tree export of a jspwiki 2.8 repository.\n"+
-                      "It is meant to be imported to the /wiki:spaces/ node of the JCR repository, as it\n"+
+                      "It is meant to be imported to the /pages/ node of the JCR repository, as it\n"+
                       "describes an entire wiki space.");
         m_out.println("-->");
         
@@ -104,7 +109,7 @@
                       "xmlns:mix='http://www.jcp.org/jcr/mix/1.0' "+ 
                       "xmlns:sv='http://www.jcp.org/jcr/sv/1.0' "+ 
                       "xmlns:wiki='"+NS_JSPWIKI+"'\n"+ 
-                      "         sv:name='"+m_engine.getApplicationName()+"'>" );
+                      "         sv:name='main'>" );
         
         for( WikiPage p : allPages )
         {
@@ -166,6 +171,15 @@
     
     protected void exportPage( WikiPage p ) throws IOException, ProviderException
     {
+        if( p.getName().contains( "/" ) && !(p instanceof Attachment) )
+        {
+            System.err.println("Unable to export '"+p.getName()+"', as it contains an illegal character.  With old repositories, this may sometimes happen.");
+            return;
+        }
+     
+        if( m_verbose )
+            System.out.println("Exporting "+p.getName());
+        
         exportCommonHeader(p);
 
         Map<String,Object> attrMap = p.getAttributes();
@@ -220,13 +234,14 @@
         //
         //  Finally, list attachment.  According to JCR rules, these must be last.
         //
+        /*
         Collection<Attachment> atts = m_engine.getAttachmentManager().listAttachments( p );
         
         for( Attachment a : atts )
         {
             exportPage( a );
         }
-        
+        */
         m_out.println(" </sv:node>");
         
         m_out.flush();
@@ -272,6 +287,7 @@
         m_out.flush();  
     }
     
+    // FIXME: Would be useful if this actually had some options checking.
     public static void main( String[] argv ) throws IOException
     {
         if( argv.length < 2 )
@@ -306,7 +322,7 @@
             out = new BufferedOutputStream( new FileOutputStream(outFile) );
             WikiEngine engine = new WikiEngine(props);
             
-            Exporter x = new Exporter(engine, out );
+            Exporter x = new Exporter(engine, out, false );
             
             x.export();
         }

Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/content/ExporterTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/content/ExporterTest.java?rev=883162&r1=883161&r2=883162&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/content/ExporterTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/content/ExporterTest.java Sun Nov 22 22:30:29 2009
@@ -34,6 +34,7 @@
         m_engine.deletePage("FooBar");
     }
     
+    // FIXME: Not yet completed.
     public void testExport1() throws Exception
     {
         m_engine.saveText( "FooBar", "test" );
@@ -42,7 +43,7 @@
         
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         
-        Exporter x = new Exporter(m_engine,out);
+        Exporter x = new Exporter(m_engine,out,false);
         
         x.export();